Skip to content

Commit

Permalink
Make cannon shot 3 way
Browse files Browse the repository at this point in the history
  • Loading branch information
akisute committed Sep 1, 2009
1 parent 40f883d commit 338e164
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions Classes/MSTGObjectFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,45 @@ - (void)initMSTGObject
self.damage = 1;
self.owner = kMSTGObjectOwnerEnemy;

fireInterval = 20;
fireFrames = 0;
fireInterval = 60;
fireFrames = fireInterval - 5;
}

- (void)mainPhase:(ccTime)dt
{
GameSceneLayer *gameSceneLayer = self.gameSceneLayer;
MSTGObject *player = gameSceneLayer.player;

// Shoot bullets at player
// Shoot 3 bullets at player
if (fireFrames++ > fireInterval)
{
fireFrames = 0;
MSTGObject *bullet = [MSTGObjectFactory bullet];
bullet.position = self.position;
Action *action = [MSTGActionFactory moveByFrom:bullet.position
MSTGObject *bullet1 = [MSTGObjectFactory bullet];
bullet1.position = self.position;
Action *action1 = [MSTGActionFactory moveByFrom:bullet1.position
to:player.position
speed:150];
[bullet runAction:action];
[gameSceneLayer addChild:bullet];
speed:100];
[bullet1 runAction:action1];
[gameSceneLayer addChild:bullet1];

MSTGObject *bullet2 = [MSTGObjectFactory bullet];
bullet2.position = self.position;
Action *action2 = [MSTGActionFactory moveByFrom:bullet2.position
to:player.position
degree:5
speed:100];
[bullet2 runAction:action2];
[gameSceneLayer addChild:bullet2];

MSTGObject *bullet3 = [MSTGObjectFactory bullet];
bullet3.position = self.position;
Action *action3 = [MSTGActionFactory moveByFrom:bullet3.position
to:player.position
degree:-5
speed:100];
[bullet3 runAction:action3];
[gameSceneLayer addChild:bullet3];
}
// [MSTGActionFactory moveByFrom:bullet.position
// to:player.position
// degree:5
// speed:150];

}

@end
Expand Down

0 comments on commit 338e164

Please sign in to comment.