Game Development Reference
In-Depth Information
_popoverMenuLayer = nil;
_gameMenuLayer.visible = YES;
_levelNode.paused = NO;
}
}
Finally, the _gameMenuLayer with the pause button is made visible again and the
_physicsNode is unpaused.
With this setup, you can show and hide popover menus quite neatly. There's only one
thing left to prepare. In GameMenuLayer.m , you should add the two methods of Listing
6-9 just below the shouldPauseGame method.
Listing 6-9 . Enabling the GameMenuLayer to resume the game by playing a specific
timeline animation
-(void) shouldResumeGame
{
CCAnimationManager* am = self.animationManager;
if ([am.runningSequenceName isEqualToString:@"resume
game"] == NO)
{
[am runAnimationsForSequenceNamed:@"resume game"];
}
}
-(void) resumeGameDidEnd
{
[_gameScene removePopover];
}
The idea here is that shouldResumeGame runs a Timeline with a specific name: re-
sume game . But only if this specific Timeline isn't currently running, to prevent the user
from tapping the resume button multiple times in quick succession and thus unintention-
ally restarting the Timeline.
Caution Timeline names are case sensitive. Because of this, it's recommended
to follow a common rule for all Timeline names—for instance, no uppercase
letters at all or camel casing, where each word begins with an uppercase letter.
Search WWH ::




Custom Search