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

Using the Prop Class: Creating Fixed Scene Objects<br />

Before we get into the coding in our InvinciBagel.java class, which you should have open in its own tab in NetBeans<br />

already, and use these Prop classes to add fixed sprite design elements to our game, I wanted to show you how to get<br />

rid of those pesky little wrench icons next to your file names. You may have several of these on your IDE screen right<br />

now, after creating these four new props-related classes, so let’s learn how to make these vanish! As you can see in<br />

Figure 14-17, if you right-click on the file name next to the wrench icon, and select the Compile File menu option,<br />

or use the F9 function key, the wrench will disappear. Essentially the wrench signifies that you are in the process of<br />

working on that file, that is, you have made changes to the code in that file, and have not made that code permanent,<br />

by compiling it to check it for errors as well as to save it.<br />

Figure 14-17. If you want to get rid of the little wrench icon next to the file name, right-click the file, and Compile File<br />

Adding Prop and Image Declarations: Prop and Image Objects<br />

Let’s start by declaring the objects that we will need to create to add fixed sprites to our game’s Scene and Stage<br />

objects, which will initially be a Prop object named iPR0, which stands for InvinciBagel Prop zero, and eventually as<br />

the chapter goes on, a PropH object named iPH0, a PropV object named iPV0, and a PropB object named iPB0, just so<br />

that you have experience using all of these classes and so that we can make sure that they all work in the way that we<br />

designed them to. We will also add an iP0 Image object declaration, and later on an iP1 Image object declaration, to<br />

the end of the Image iB0 through iB8 declarations. The <strong>Java</strong> statements are shown in Figure 14-18, and look like this:<br />

Prop iPR0;<br />

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

310<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!