Skip to content

Instantly share code, notes, and snippets.

@kyokomi
Last active August 29, 2015 13:57
Show Gist options
  • Save kyokomi/9563902 to your computer and use it in GitHub Desktop.
Save kyokomi/9563902 to your computer and use it in GitHub Desktop.
EventDispatherについての調査資料2
// 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);
}
// ローグ用のフォアグラウンドイベント
#define EVENT_COME_TO_FOREGROUND_ROGUE "EVENT_COME_TO_FOREGROUND_ROGUE"
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