Game Development Reference
In-Depth Information
// call bullet countrer from time to time
[self schedule:@selector(countBullets:) interval:3];
BulletCache* bulletCache = [BulletCache node];
[self addChild:bulletCache z:1 tag:GameSceneNodeTagBulletCache];
You should then add the initialization of the BulletCache class in place of the re-
moved code from Listing 8-2 and also import the BulletCache.h header file at the
top of the GameLayer.m implementation file.
Listing 8-3. Import the BulletCache Header and Add the BulletCache Initialization to
the init Method
#import"BulletCache.h"
. . .
-(id) init
{
if ((self = [super init]))
{
. . .
BulletCache* bulletCache = [BulletCache node];
[self addChild:bulletCache z:1 tag:GameSceneNodeTagBulletCache];
}
return self;
}
You will also have to add GameSceneNodeTagBulletCache to the GameS-
ceneNodeTags enum in the GameLayer.h file, and you have to add a bul-
letCache accessor method so other classes can access the BulletCache instance
through the GameLayer . You can add this method just next to the defaultShip
method:
-(BulletCache*) bulletCache
{
Search Nedrilad ::




Custom Search