Making spaceship fire

Nobody would face an alien invasion with a harmless spaceship, so we are going to make it fire.

We need to create a variable to manage bullet_mc DisplayObject and I have said the spaceship can fire only one bullet at a time, so we need another variable to tell us if the spaceship is already firing. If it's firing, it cannot fire. If it's not firing, it can fire.

Add two new class level variables:

private var spaceship:spaceship_mc;
private var isFiring:Boolean=false;
private var bullet:bullet_mc;

isFiring is the Boolean variable that we'll use to determine if the spaceship is firing. false means it's not firing.

bullet will represent the bullet itself.

The player will be able to fire with mouse click, so a listener is needed ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.