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 6 ■ The Foundation of Game Design: The <strong>Java</strong>FX Scene Graph and the InvinciBagel Game Infrastructure<br />

Scene Graph Assets: Installing the ImageView’s Image Assets in Your Project<br />

To reference the digital image assets inside the JAR file in your <strong>Java</strong> code, you have to insert a forward slash before the<br />

file name. Before you can reference the files, however, you must copy these image files from the book repository into<br />

the Computer/ComputerName/Users/user/MyDocuments/NetBeansProjects/InvinciBagel/src folder, as shown<br />

on the left-hand side (and the top) of Figure 6-6. You can also see how these digital image assets will composite, as the<br />

background plate invincibagelsplash PNG24 has a spot for the other three PNG32 images to overlay (cover). The white<br />

areas seen in the composite ImageView assets are actually transparent! Now, you are ready!<br />

Figure 6-6. Windows 7 Explorer file management utility, showing a PNG24 splash screen and three PNG32 overlays<br />

<strong>Java</strong>FX UI Classes: HBox, Pos, Insets, and ImageView<br />

Let’s take a break from coding for an in-depth look at some of the new classes you are going to use to complete your<br />

top-level game application UI design. These include the Pos class (positioning); the Insets class (padding); the HBox<br />

class (UI layout container); the Image class (digital image container); the ImageView class (digital image display);<br />

and the TableView class (table data display), which you will study here but implement in code later in your game<br />

development once the game is completely finished. You will examine these in order, from simplest (Pos) to most<br />

complex (TableView), and then code the .createSplashScreenNodes() and .addNodesToStackPane() methods,<br />

which use these new classes (objects).<br />

The <strong>Java</strong>FX Pos Class: Generalized Screen Position Constants<br />

The Pos class is an Enum class, which stands for “enumeration.” This class contains a list of constants that are<br />

translated into integer values for use in the code. The constant values (in this case, positioning constants, such as TOP,<br />

CENTER, and BASELINE) make it easier for programmers to use these values in their code.<br />

www.it-ebooks.info<br />

129

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

Saved successfully!

Ooh no, something went wrong!