viewDidAppearとかviewWillAppearみたいなのが無さそうなので。(あったら教えて下さい)
HelloWorldSceneのhogeメソッドを読んでいます。
AppDelegate.cpp
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->startAnimation();
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
// getRunningSceneでCCSceneをとってその上のレイヤーにアクセスする。
CCLayer *sceneLayer = (CCLayer*)CCDirector::sharedDirector()->getRunningScene()->getChildren()->lastObject();
if (typeid(*sceneLayer) == typeid(HelloWorld)) {
HelloWorld *helloWold = (HelloWorld*)sceneLayer;
helloWold->hoge();
}
}
getRunningSceneでそのままアクセスできると思ってしばらくハマってました。
sceneメソッド見て納得。
0 件のコメント:
コメントを投稿