28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 14 ■ Setting Up the Game Environment: Creating Fixed Sprite Classes Using the Actor Superclass<br />

Figure 14-21. Instantiate an iPR0 Prop object, add it to the root Scene Graph, and add it to the CurrentCast List<br />

The next step is to add the ImageView Node object for the iPR0 Prop object to the Scene Graph root object. This<br />

is done using a .getChildren().add() method chain, which references the spriteFrame ImageView object, inside of<br />

the iPR0 Prop object using dot notation, using the following <strong>Java</strong> statement, which is also shown in Figure 14-21:<br />

root.getChildren().add(iPR0.spriteFrame);<br />

Next, use an .addCurrentCast() method to add an iPR0 object to a castDirector object, seen in Figure 14-21:<br />

castDirector.addCurrentCast(iPR0);<br />

Next, test the code using a Run ➤ Project work process. The results are seen on the left side of Figure 14-22.<br />

Figure 14-22. Testing InvinciBagel 0,0 prop placement (left) and changing the z-index in .addGameActorNodes() (right)<br />

www.it-ebooks.info<br />

313

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

Saved successfully!

Ooh no, something went wrong!