开发者

iPhone - starting cocos2d scene from viewcontroller, closing from within scene

How do I do this?

On one of my UIViews (nib file) I have ImageView and a Button that starts full screen Cocos2d scene. From within that scene I want to close it and go back to UIView, so that user can later open the scene again but from different image in ImageView (and with different content on scene).

However, after the first time I "close" the scene the whole app reacts a lot slower to all touch events. It works fast as long as th开发者_如何学Ce scene is on, but when closed then performance goes down.

How should I properly close the scene so that I can restart it again? I've browsed through a lot of code samples and everywhere is just replaceWithScene:newScene.


Adding a UIView to a viewController that houses a running openGL layer slows the app, as anyone who has tried to incorporate a UIScrollView into a Cocos2D game can tell you. You are closing the scene, but likely not stopping the CCDirector, which is now running its own scheduler aside the application's scheduler. As they fight for dominance over the CPU, OpenGL invariably wins as it needs more power more often.

Ensure you are completely shutting down cocos2D and OpenGL. Even if only calling [[CCDirector sharedDirector] pause].

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜