1
votes

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?

2
could you add some code your pause and resume methods etc...u.gen

2 Answers

1
votes

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.

1
votes

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

  • don't replace the scene
  • push/pop the other scene
  • write code to save the scene's state and restore it