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

Now, it is time for the final testing of the top-level UI part of your game application to make sure that all the UI<br />

button elements (objects) function properly and do what you have designed (coded) them to do. After that, you will be<br />

running the NetBeans 8.0 Profiler again to ensure that the Scene Graph hierarchy that you have just created is indeed<br />

leaving 99 percent of the available CPU processing power for the game engines that you will be creating from here on.<br />

Testing the Final InvinciBagel UI Design<br />

Again, click the green Play arrow at the top of NetBeans IDE 8.0, and run your project. This will bring up the windows<br />

demonstrated in Figure 6-12. As you can see, when you click the Legal and Credits button UI element, the overlay<br />

makes a seamless composite with the InvinciBagel artwork backplate, as shown on the left-hand side of the figure,<br />

and when the High Scores button UI element (control) is clicked, the high scores table background is put in place,<br />

as displayed on the right-hand side of the figure. As you can see, the classes from the javafx.image package provide a<br />

pristine result with regard to compositing<br />

Figure 6-12. The other two Image objects shown composited, using the background plate and compositing ImageViews<br />

Next, let’s take a look at how many CPU cycles are being taken up by the Scene Graph implementation that you<br />

have coded in this chapter, as you want to ensure a 100 percent static, top-level UI design so that the only dynamic<br />

elements used in your game are the game play engine (and related engines) themselves. Because the traversal of the<br />

Scene Graph hierarchy by the pulse resolution engine can get “expensive,” you need to be very careful here!<br />

Remember that your primary objective is to create a top-level UI design for starting the game play screen<br />

and loop, while also implementing a UI that allows your users to display the instructions, legal disclaimers, and<br />

production credits and take care of setting up an area to use for displaying the high scores table. At the same time,<br />

you are tasked with saving 99 percent of the processing power for use later on, for processing the game logic, sprite<br />

movements, sprite animation, collision detection, scoring, and physics via the <strong>Java</strong>FX pulse engine.<br />

Profiling the InvinciBagel Scene Graph for Pulse Efficiency<br />

It is important that the game UI design not take any processing power away from the CPU, as the game engine is going<br />

to need all of it. As Figure 6-13 reveals, you can use the Profile > Profile Project (InvinciBagel) menu sequence to<br />

run the Profiler and take a screenshot of the CPU statistics for the current (top-level UI) application.<br />

142<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!