Question

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 the 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.

Was it helpful?

Solution

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].

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top