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 8 ■ Creating Your Actor Engine: Design the Characters for Your Game and Define Their Capabilities<br />

Since <strong>Java</strong>FX can flip or mirror images on the X or Y axis, this means I can reverse a sprite direction (left or right)<br />

using FlipV or orientation (up or down) using FlipH.<br />

These six additional Boolean flag fixed (Actor) sprite attributes will be declared by using protected boolean data<br />

variables, using the following six lines of <strong>Java</strong> 8 code, as is shown (error free, no less) in Figure 8-7:<br />

protected boolean isAlive;<br />

protected boolean isFixed;<br />

protected boolean isBonus;<br />

protected boolean hasValu;<br />

protected boolean isFlipV;<br />

protected boolean isFlipH;<br />

Figure 8-7. Add the rest of the variables needed to support rotation (pivot point), and sprite definition states<br />

Next, we’ll initialize these variables, inside the Actor() constructor method. If you wanted to pass settings to<br />

any of these Boolean flags into the Actor() constructor method using the parameter list, remember that you’re<br />

able to create as many overloaded constructor method formats as you like, as long as the parameter list for each<br />

one is 100% unique. We may well do this later on during the book, if, for instance, we need a constructor method<br />

that pivots our fixed sprites for layout design purposes, for instance, or one that flips it around a given axis, for<br />

instance, for the same exact purpose, or one that does both of these, which would give us a nine parameter Actor()<br />

constructor method call.<br />

172<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!