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 />

You can also “flip” large props, creating some very cool effects. Create an iPV1 declaration and instantiation, as<br />

seen in Figure 14-31, and create a PropV object, which will mirror the moss rock, along the X axis. This can be seen on<br />

the right side of Figure 14-30. We’ve made a lot of progress in this chapter using fixed sprite Prop class capabilities.<br />

Figure 14-31. Instantiate an iPV1 PropV object, add it to the root Scene Graph, and add it to a CurrentCast List<br />

Summary<br />

In this fourteenth chapter, we created our fixed sprite “prop” classes that allow us to design our game scenes and the<br />

fixed objects that our motion sprite Actor objects will interact with. We first created the Prop class, which extends<br />

the Actor class that we created during Chapter 8. We used the .setTranslateX() and .setTranslateY() methods to take<br />

the xLocation and yLocation parameters in the constructor method to position the ImageView on the Stage, similar<br />

to what we did with the .moveInvinciBagel() class, only with fixed sprites a move is only made once, inside of the<br />

constructor method, to position the prop in the Scene on the Stage.<br />

Next we created even more complicated PropH and PropV classes, which in addition to positioning the<br />

fixed sprites in the Scene, also mirror them automatically, around the Y axis (PropH) and X axis (PropV). We also<br />

created a PropB (B stands for Both) class that will automatically mirror fixed sprite Image assets around both the<br />

X and Y axes.<br />

Next, we learned how to implement these Prop classes by declaring, instantiating, and adding (to the <strong>Java</strong>FX<br />

Scene Graph as well as to the CastingDirector object) them inside of our InvinciBagel.java primary game design class.<br />

We learned how to position our fixed sprites on the screen, as well as how to create seamless mirrored tiling effects,<br />

and tested our new Prop classes to make sure they were ready for use in designing game play levels.<br />

320<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!