Reputation: 1035
I have a pause button that's a CCMenuItem
that when I touch it, the app goes to the menu. I have the Game Scene set as a static variable on the Menu Scene so that when I resume the game I can resume my current game.
When I press the resume button, I reschedule the update on the Game Scene and replaceScene with the static Game Scene. The pause button is on a layer that the Game Scene owns.
When the game continues, the pause button is there but doesn't respond to my touch. I tried using onEnter to do resumeSchedulerAndActions but nothing.
I've come up with a solution which feels hacky, which is to create my menu in onEnter
and remove it in onExit
.
Am I missing something? Is there a way to make my menu respond to touches again?
Upvotes: 1
Views: 498
Reputation: 64477
You know what's hacky? Keeping a scene in a static variable. If you replace a scene, you're supposed to let go of it. Cocos2d doesn't handle multiple calls to replaceScene with the same object correctly. Either this, or overriding onEnter and not calling [super onEnter] is causing the input problems.
If you want to continue the game, either
Upvotes: 1
Reputation: 5664
You could use popScene
of CCDirector
to pop the menu scene from the game scene. You may not have to hack around with scheduling yourself. For this to work, the pause button would have to push the scene on the scenes stack in the first place instead of using replaceScene
.
Upvotes: 1