This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() | |
| { | |
| // 'non_volatile_int == 1' will be optimized to be 'true' by compiler | |
| int non_volatile_int = 1; | |
| while( non_volatile_int == 1 /* true */ ) | |
| { | |
| // code | |
| } | |
| // 'volatile_int == 1' won't be optimized by compiler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using std::cout; | |
| using std::endl; | |
| static int SomeDataSource = 100; | |
| class LazyFetching | |
| { | |
| public: | |
| LazyFetching() : m_pDataSource( nullptr ) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| #include <map> | |
| using namespace std; | |
| struct Employee { | |
| string m_name; | |
| int m_cubicleNumber; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // From Kirill V. Lyadvinsky | |
| // http://stackoverflow.com/questions/860339/difference-between-private-public-and-protected-inheritance | |
| class A | |
| { | |
| public: | |
| int x; | |
| protected: | |
| int y; | |
| private: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # OSX - https://github.com/github/gitignore/blob/master/Global/OSX.gitignore | |
| .DS_Store | |
| .AppleDouble | |
| .LSOverride | |
| # Icon must end with two \r | |
| Icon | |
| # Thumbnails |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // lamda example | |
| void lamdaA ( cocos2d::Node* node ) | |
| { | |
| auto button = node->getChildByName< cocos2d::ui::Button* >( "Button_team" ); | |
| if( button ) | |
| { | |
| button->addTouchEventListener( [ = ]( cocos2d::Ref*, cocos2d::ui::Widget::TouchEventType type ) { | |
| if( type == cocos2d::ui::Widget::TouchEventType::ENDED ) { | |
| // do something | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "cocos2d.h" | |
| void SomeNode::setup() { | |
| auto dispatcher = Director::getInstance()->getEventDispatcher(); | |
| auto listener = EventListenerTouchOneByOne::create(); | |
| listener->onTouchBegan = CC_CALLBACK_2( SomeNode::onTouchBegan, this ); | |
| listener->onTouchEnded = CC_CALLBACK_2( SomeNode::onTouchEnded, this ); | |
| dispatcher->addEventListenerWithSceneGraphPriority( listener, this ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| std::shared_ptr<const DownloadTask> Downloader::createDownloadDataTask(const std::string& srcUrl, const std::string& identifier/* = ""*/) | |
| { | |
| DownloadTask *task_ = new DownloadTask(); | |
| std::shared_ptr<const DownloadTask> task(task_); | |
| do | |
| { | |
| task_->requestURL = srcUrl; | |
| task_->identifier = identifier; | |
| if (0 == srcUrl.length()) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void AssetsManager::downloadAndUncompress() | |
| { | |
| std::thread([this]() | |
| { | |
| do | |
| { | |
| // Uncompress zip file. | |
| if (! uncompress()) | |
| { | |
| Director::getInstance()->getScheduler()->performFunctionInCocosThread([&, this]{ |