Game Development Reference
In-Depth Information
Create a new Objective-C class just like you did in the last chapter with the Trigger and
PlayTimelineWhenTriggered classes. This time, name the new class
GameMenuLayer and make it a subclass of CCNode . Look at Figure 2-10 and Figure
2-11 if you need to refresh your memory.
Adding the class satisfies the requirement created by assigning GameMenuLayer as the
custom class of the GameMenuLayer.ccb root node. You can confirm that the class is in-
stantiated at least once by adding the code in Listing 6-1 to merely log whenever a node
with this class has been loaded by CCBReader .
Listing 6-1 . Logging confirms that at least one node using the GameMenuLayer class is
loaded
#import "GameMenuLayer.h"
#import "GameScene.h"
@implementation GameMenuLayer
-(void) didLoadFromCCB
{
NSLog(@“YAY! didLoadFromCCB: %@", self);
}
-(void) shouldPauseGame
{
NSLog(@"BUTTON: should pause game");
}
@end
To satisfy the _gameMenuLayer variable assignment to GameScene.ccb 's root node,
open GameScene.m to import the new GameMenuLayer class and to add the
_gameMenuLayer ivar at the top of the file as highlighted in Listing 6-2 .
You will also add a _popoverMenuLayer reference that will be used as the reference
to the currently displayed popover layer drawn over the current level while the level is
paused. The popover layers for this game are displayed when the player dies, the player
makes it to the exit, or the pause button is tapped to bring up the pause menu.
Listing 6-2 . Adding the _gameMenuLayer ivar to GameScene.m
#import "GameScene.h"
#import "Trigger.h"
Search WWH ::




Custom Search