Game Development Reference
In-Depth Information
visibility into the InvinciBagel class. Thus, the first thing that we'll need to do is to
modify the Enemy() constructor method to accept an InvinciBagel object using the
Java this keyword, much like we did with our Bagel() constructor method. Go into the
InvinciBagel.java class and add a this keyword to the front end of (beginning of) your
Enemy() constructor parameter list, as shown highlighted in Figure 17-39 , using the
following amended Enemy() constructor method call:
iBeagle = new Enemy ( this , "M0 6 L0 52 70 52 70 70 70 93
115 45 115 0 84 0 68 16 Z",520,160,iE0);
Figure 17-39 . Add a Java this keyword inside the Enemy() constructor method call to pass over the InvinciBagel
object
For this to work, you need to also update your Enemy.java class to accommodate
the InvinciBagel object. Add an InvinciBagel invinciBagel; object declara-
tion, at the top of the Enemy.java class, and edit your Enemy() constructor method to
support this object by adding an InvinciBagel iBagel parameter at the head end (begin-
ning) of the parameter list definition. Inside of the Enemy() constructor method, set the
invinciBagel InvinciBagel object equal to the iBagel InvinciBagel object reference
passed into the Enemy() constructor method in its parameter list. The Java code for the
amended Enemy() constructor method body is shown in Figure 17-40 , and should look
like the following:
InvinciBagel invinciBagel;
public Enemy( InvinciBagel iBagel ,
String SVGdata, double xLocation, double
yLocation, Image... spriteCels) {
super(SVGdata, xLocation, yLocation, spriteCels);
 
 
 
Search WWH ::




Custom Search