Game Development Reference
In-Depth Information
Listing 8-13. The StandardShootComponent Implementation in Its Entirety
#import "StandardShootComponent.h"
#import "BulletCache.h"
#import "GameLayer.h"
@implementation StandardShootComponent
@synthesize shootFrequency;
@synthesize bulletFrameName;
-(id) init
{
if ((self = [super init]))
{
[self scheduleUpdate];
}
return self;
}
-(void) update:(ccTime)delta
{
if (self.parent.visible)
{
updateCount + = delta;
if (updateCount > = shootFrequency)
{
updateCount = 0;
GameLayer* game = [GameLayer sharedGameLayer];
CGPoint startPos = ccpSub(self.parent.position, ←
CGPointMake(self.parent.contentSize.width * 0.5f, 0));
[game.bulletCache shootBulletFrom:startPos
velocity:CGPointMake(−200, 0)
frameName:bulletFrameName];
}
}
 
Search Nedrilad ::




Custom Search