开发者

Which cocos2d scene is currently active when returning from suspended app state

The environment is an iOS device with multitasking support, like an iPhone4. I'm in a cocos2d app with a Main Menu that lead开发者_JAVA百科s to several Scenes.

Which cocos2d scene is currently active when returning from suspended app state

If I switch to another app using the taskbar, then switch back, how do I programmatically tell which scene is active?


Couldn't you just check CCDirector's runningScene property in your app delegate's applicationWillEnterForeground: method? If you subclass CCScene you could just check the scene's class, otherwise you may want to add some other sort of identifier to each scene.


you could add an identifier for the CCSCene class such as int sceneID or typedef enum { mainMenuID = 0, playSceneID, helpSceneID, aboutSceneID } sceneID and then simply assign each of these in the init method of each scene... then you can retrieve it in applicationWillEnterForeground: like so:

int theSceneID = [[[CCDirector sharedDirector] runningScene] classID];

but like Zaid suggested, it is alot easier to use the tag of CCScene.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜