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 7 ■ The Foundation of Game Play Loop: The <strong>Java</strong>FX Pulse System and the Game Processing Architecture<br />

Figure 7-22. Run the Threads Profiler<br />

Given the empty .handle() method processing from the GamePlayLoop object in Thread-6 (see Figure 7-18), you<br />

can assume that the pulse events in Thread-6 are from the GamePlayLoop AnimationTimer subclass. This means that<br />

the pulse events showing in the <strong>Java</strong>FX Application Thread are showing where the .handle() method is accessing a<br />

buttonContainer HBox object contained in a stackPane Scene Graph root in the InvinciBagel class.<br />

Now, you have a low-overhead, extremely fast game processing loop in place, and you can start to create your<br />

other (sprite, collision, physics, scoring, logic, and so on) game engines! One down, and a whole bunch to go!<br />

Summary<br />

In this seventh chapter, you wrote the first of the many game engines that you will be designing and coding over the<br />

course of this book, the GamePlayLoop game play timing class and object, which allow you to tap into the powerful<br />

<strong>Java</strong>FX pulse event processing system.<br />

First, you examined the different classes in the javafx.animation package and the different ways to use the<br />

Animation, Transition, Timeline, and AnimationTimer classes to harness the <strong>Java</strong>FX pulse event processing system.<br />

After that, you learned how to create a new <strong>Java</strong> class in NetBeans and then extended the AnimationTimer<br />

superclass to create the GamePlayLoop subclass, which will process your game play logic at 60FPS. You saw how<br />

to use NetBeans to help you write the majority of the code for this new subclass, including the package and class<br />

statement, the import statement, and the bootstrap .handle() method.<br />

www.it-ebooks.info<br />

163

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

Saved successfully!

Ooh no, something went wrong!