如何直接杀死cocos2d场景而不替换场景 [英] How to kill a cocos2d scene directly without replacing scene
问题描述
我使用UIViewController以这种方式启动游戏:
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];
确定,现在当我想退出我只是替换UIViewController(因为我做了菜单UIKit和游戏cocos2d)与启动视图控制器做我想要的动画,它工作正常...但显然旧的运行场景仍然保留在内存中,它不是以任何方式解除分配,我需要删除的场景和使应用程序在第一次运行。
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.
replaceScene没有工作,我只需要停止运行的场景,做一切,因为它是当应用程序开始运行,从[CCDirector sharedDirector]直接,我该怎么办?
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.
推荐答案
您可以从应用程序中删除CCDirector。
you can remove the CCDirector from the application.
导演是一个简单的UIViewController所以,你可以调用
the director is a simple UIViewController so, you can call
[[CCDirector sharedDirector] removeFromParentViewController];
,然后调用 [[CCDirector sharedDirector] end];
删除singlenton实例
and after call the [[CCDirector sharedDirector] end];
to remove the singlenton instance
这篇关于如何直接杀死cocos2d场景而不替换场景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!