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

Use Run ➤ Project and test the game to see how each brick is mirrored differently, as shown in Figure 14-26.<br />

Figure 14-26. Run ➤ Project; Prop, PropH, and PropV shown at the left, and all four Prop subclasses shown at the right<br />

Next, let’s take a look at how to use large Scene Prop objects to composite background elements on a Stage.<br />

Using Larger Scene Props: Compositing with <strong>Java</strong>FX<br />

One thing that is really nice about these four Prop Actor subclasses that we have created is that they allow us to<br />

leverage the PNG8 (background image assets) and PNG32 (true color compositing images with alpha channels) image<br />

assets to do digital image compositing right in our game Scene and Stage objects. If we do not use a fixed prop with a<br />

motion sprite game character by implementing collision detection, and if we keep these fix props in the background,<br />

by watching what we’re doing inside of our .addGameActorNodes() method as far as Actor z-index goes, we can<br />

optimize game visual elements using the same compositing engine we have developed for characters and obstacles.<br />

We might not have to use any background image plates for our game at all. At the very least, this allows us to add<br />

simpler background image plates, such as a basic sky with clouds, or a sunset. These compress better, due to their<br />

simplicity, and can use PNG8 images with pristine results. Let’s add a larger fixed sprite prop next, one that has nearly<br />

500 pixels of width and nearly 100 pixels of height. The first thing that we’ll need to add, as shown in Figure 14-27, is<br />

another Prop object that we’ll name iPR1, and another Image object that we’ll name iP1, using the following code:<br />

Prop iPR0, iPR1;<br />

private Image iB0, iB1, iB2, iB3, iB4, iB5, iB6, iB7, iB8, iP0, iP1;<br />

www.it-ebooks.info<br />

317

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

Saved successfully!

Ooh no, something went wrong!