How to kill a cocos2d scene directly without replacing scene

可紊 提交于 2019-12-13 06:26:12

问题


I'm starting the game with a UIViewController in this way:

navController = [[MyNavigationController alloc] initWithRootViewController:myController];

and when you push the game button the game start the scene in this way:

[[CCDirector sharedDirector] runWithScene:gameScene];

ok, now when I want to quit I just replace the UIViewController (because I did the menu with UIKit and the game with cocos2d) with the starting view controller to do the animation I want, it works fine... but obviously the old running scene still remains in memory, it is not deallocated in any way, I need to remove the scene and make the app as it was at the first running.

The replaceScene didn't work, I just need to stop the running scene and make everything as it was when the app started running, from the [CCDirector sharedDirector] direcly, how can I do it? popScene won't work too.


回答1:


you can remove the CCDirector from the application.

the director is a simple UIViewController so, you can call

[[CCDirector sharedDirector] removeFromParentViewController];

and after call the [[CCDirector sharedDirector] end]; to remove the singlenton instance



来源:https://stackoverflow.com/questions/16224795/how-to-kill-a-cocos2d-scene-directly-without-replacing-scene

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!