28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 17 ■ Enhancing Game Play: Creating a Scoring Engine, Adding Treasure and an Enemy Auto-Attack Engine<br />

Tweaking a Game: Fine-Tuning the User Experience<br />

Let’s take a moment and make a couple of adjustments to the code now that the auto-attack logic is working, to make<br />

sure that our game play is professional. Place the iBeagle, iBullet, and iCheese objects off-screen at game start-up,<br />

by changing the X and Y location parameters in each of these object’s constructor methods with negative X location<br />

values that are the same as (or greater than) the width of the sprite image asset, as can be seen in Figure 17-52.<br />

Figure 17-52. Modify X and Y parameters for all Enemy and Projectile constructor methods, to place them off-screen<br />

You also may have noticed that the Projectile objects are on top of the Enemy’s bazooka, so let’s change the<br />

z-index of the iBeagle object, so the projectiles come from behind the gun. To do this, put your .add() method call for<br />

the iBeagle after iBullet, and before iBagel, at the end of the .addGameActorNodes() method, as seen in Figure 17-53.<br />

Figure 17-53. Change z-index of iCheese and iBullet in the addGameActorNodes() method so they’re before iBeagle<br />

446<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!