Game Development Reference
In-Depth Information
invinciBagel = iBagel;
spriteFrame.setTranslateX(xLocation);
spriteFrame.setTranslateY(yLocation);
isAlive = true;
isBonus = true;
hasValu = true;
}
Figure 17-40 . Modify the Enemy() constructor method in the Enemy class to add an InvinciBagel object named iBagel
Now that the Enemy class (object) can see into the InvinciBagel class (object),
we're ready to add projectiles.
Creating a Projectile Infrastructure: Adding Projectile
Variables
To add projectile support to the Enemy class we will need to declare four new variables
at the top of the class. These will include randomLocation, a new variable that we'll
use for both the Enemy character and the projectile he shoots; randomOffset, a new
variable that will hold the vertical (Y) offset that allows us to fine-tune position the
projectile so that it comes out of the bazooka barrel; and the bulletRange and bulletOff-
 
Search WWH ::




Custom Search