All this running around and hitting walls is fine and good, but we need to be able to shoot, don't we? As you may recall from our discussion of the TDControlLayer
class, you will recall that when the button is pressed we simply set the Boolean variable heroShooting
to YES
. We handle this value in the TDPlayfieldLayer
update method.
-(void) update:(ccTime) dt { // If the shoot button is pressed if (heroShooting) { // We limit the hero's shoot speed to avoid // massive "bullet rain" effect if (currHeroShootSpeed > 0) { currHeroShootSpeed -= dt; } else { // Ready to shoot [hero shoot]; currHeroShootSpeed = shootSpeed; } } else { // Get ready to shoot next press currHeroShootSpeed = 0; } // Move the enemies // Move the bullets // Check collisions // Is the game over? if (isGameOver) { [self...