28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 6 ■ The Foundation of Game Design: The <strong>Java</strong>FX Scene Graph and the InvinciBagel Game Infrastructure<br />

Finally, let’s do the same thing for the image-compositing plate, that is, the ImageView that will hold the different<br />

Image objects containing the alpha channel (transparency) values that will create an overlay of panel images for the<br />

InvinciBagel splash screen artwork (which was created by the talented 2D artist Patrick Harrington):<br />

instructionLayer = new Image("/invincibagelinstruct.png", 640, 400, true, false, true);<br />

splashScreenTextArea = new ImageView();<br />

splashScreenTextArea.setImage(instructionLayer); // this <strong>Java</strong> statement connects the two objects<br />

As Figure 6-7 demonstrates, your Scene Graph node creation (seen at the top of the InvinciBagel class) and the<br />

Node object instantiation and configuration (seen in the createSplashScreenNodes() method) are in place and error<br />

free. You still need to add in the Image objects for the other two screens, but there is enough code here to be able to<br />

add these Node objects to the Scene Graph, using the addNodesToStackPane() method, and then test the code to<br />

make sure that it is working. According to the NetBeans IDE, this code is error free!<br />

Figure 6-7. Coding the createSplashScreenNodes() method; instantiating and configuring the nodes in the Scene Graph<br />

Next, let’s add the Node objects to the StackPane Scene Graph root object in an addNodesToStackPane() method.<br />

www.it-ebooks.info<br />

137

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

Saved successfully!

Ooh no, something went wrong!