CCMenuitem not working properly after pushing the scene for the second time

116 Views Asked by At

I have a menuScene which has a play button.
I have declared gameScene as a property in menuScene

    @property(nonatomic, strong) id gameScene; 

and now allocating the gameScene in init method of menuScene as below.

    self.gameScene = [GameScene scene];

When the user presses the play button I am pushing the gameScene, as shown below

    [[CCDirector sharedDirector] pushScene:self.gameScene];

Now when I press the pause button in the gameScene, am pausing the game and showing the options menu which has resume and menu buttons.

    -(void)pauseButtonClicked {
       [CCDirector sharedDirector] pause];
       /*code to display options menu*/
    }

I am popping to the menuScene on click of menu button,

       - (void)menuButtonClicked {
          [self removeChild:pauseLayer cleanup:YES];
          [[CCDirector sharedDirector] resume];
          [[CCDirector sharedDirector] popScene];
       }

Now if I press play button again as I have declared gameScene as a property, I am pushing the same gameScene to show the current state of the game, from now pause button is not detecting touches in the gameScene..

0

There are 0 best solutions below