Connor
Connor

Reputation: 64684

cocos2d unresponsive scene after opening for the second time

I'm having an issue going back and forth between my Menu scene and Preferences scene in my cocos2d project. I start in the Menu and when a user clicks a button it takes them to the preferences scene.

[[CCDirector sharedDirector] pushScene:[CCTransitionSlideInR transitionWithDuration:.3 scene:prefScene]];

The preferences scene has a back button to take the user back to the menu.

[[CCDirector sharedDirector] popScene];

This works fine unless the user exits the preferences scene and then tries to go back into it. The second time the preferences scene is opened all of the buttons animate when they are touched but are otherwise unresponsive.

Thanks for the help!

Upvotes: 0

Views: 75

Answers (1)

Mitchell Currie
Mitchell Currie

Reputation: 2809

I have had something similar, there were two solutions I found:

  • Quick and Dirty is to create the preferences scene instance as you need it (lazy loading), this will reduce memory of keeping it around unless you need it, but you will have to initialize it each time, however it should be new clean copy each time, and if the user doesn't click preferences every time probably faster to load the whole game.

  • Make sure the preferences scene cleans itself up before it disappears, this especially means stop all Scheduled selectors or interval timers and remove delegates and touch events.

Upvotes: 1

Related Questions