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 11 ■ Moving Your Action Figure in 2D: Controlling the X and Y Display Screen Coordinates<br />

By having your .addNodesToStackPane() method called after your .addGameActorNodes() method, you will<br />

guarantee that your game assets will always be at a lower Z-index than your Splashscreen assets. This means that the<br />

SplashScreenBackplate and the SplashScreenTextArea ImageView “plates” will always be at the top Z-index layers<br />

in the StackPane, and thus, when these are displayed (made visible), they will completely cover your game play. This<br />

is because the SplashScreenBackplate ImageView contains an opaque PNG24 image asset that is the same size as your<br />

Scene (and Stage) object.<br />

We will be seeing the result of this method order reorganization later on when we test the new InvinciBagel<br />

game application, and you will see that we have resolved this problem of the game actor(s) displaying on top of the<br />

Splashscreen. We accomplished this simply by changing the order that your programming code is executed in. This<br />

should also point out to you that the order that the <strong>Java</strong> programming code is executed in is almost as important as the<br />

<strong>Java</strong> programming logic itself!<br />

Creating and Managing Your Cast: .createCastingDirection()<br />

Now the time has come to implement the other class that we created in Chapter 10, the CastingDirector.java class,<br />

and its CastingDirector() constructor method. We will do this inside of another new custom method we will create<br />

called .createCastingDirection(). This method will contain the initial instantiation of a CastingDirector object named<br />

castDirector, which we will create by using the <strong>Java</strong> new keyword and the CastingDirector() constructor method, as<br />

well as adding the iBagel Actor object to the castDirector object, using the .addCurrentCast() method that we created<br />

in Chapter 10. The <strong>Java</strong> method structure, which is shown error-free in Figure 11-8, should look like the following:<br />

private void createCastingDirection() {<br />

castDirector = new CastingDirector();<br />

castDirector.addCurrentCast(iBagel);<br />

}<br />

Figure 11-8. Create private void createCastingDirection() method with castDirector and .addCurrentCast() statements<br />

238<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!