Last active
August 29, 2015 13:57
-
-
Save kyokomi/9563902 to your computer and use it in GitHub Desktop.
EventDispatherについての調査資料2
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
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too | |
void AppDelegate::applicationWillEnterForeground() { | |
Director::getInstance()->stopAnimation(); | |
// if you use SimpleAudioEngine, it must be pause | |
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); | |
// フォアグラウンド時のイベントを発行 | |
cocos2d::EventCustom foreground_event_rgoue(EVENT_COME_TO_FOREGROUND_ROGUE); | |
Director::getInstance()->getEventDispatcher()->dispatchEvent(&foreground_event_rgoue); | |
} |
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
// ローグ用のフォアグラウンドイベント | |
#define EVENT_COME_TO_FOREGROUND_ROGUE "EVENT_COME_TO_FOREGROUND_ROGUE" |
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
bool RogueScene::init() { | |
// ... 省略 ... | |
auto foreground_listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ | |
this->showCommonWindow("Event版 再開します。", [this](Ref* pSender){ | |
this->hideCommonWindow(); | |
}, [this](Ref* pSender){ | |
this->hideCommonWindow(); | |
}); | |
}); | |
this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(foreground_listener, this); | |
// ... 省略 ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment