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

Once NetBeans adds the import javafx.animation.AnimationTimer; programming statement, you will be<br />

ready to start creating this class, which will harness the <strong>Java</strong>FX pulse engine for you and contain all your core game<br />

play loop processing, or calls to classes and methods that will perform the various types of processing, such as sprite<br />

movement, sprite animation, collision detection, physics simulation, game logic, audio processing, AI, scoreboard<br />

updates, and the like.<br />

Creating the GamePlayLoop Class Structure: Implementing<br />

Your .handle( ) Method<br />

Note that once the import statement has been written for you by NetBeans, yet another wavy red error highlight<br />

appears below the GamePlayLoop class name. Mouse over this to find out what the error message is relating to this<br />

newest error. As Figure 7-6 demonstrates, the .handle() method required for every AnimationTimer subclass has not<br />

yet been implemented (also called overridden) in this GamePlayLoop.java class, so you have to do this next. Maybe<br />

you can even get NetBeans to write the code for you; let’s take a look, and see!<br />

Figure 7-6. Once you extend and import AnimationTimer, NetBeans throws an error: class does not implement<br />

the .handle()<br />

As you can see at the bottom left of the error message pop-up, you can use the Alt+Enter keystroke combination<br />

to bring up a helper dialog, which will offer you several solutions, including one that will actually write the<br />

unimplemented .handle() method for you. Select Implement all abstract methods, shown in Figure 7-7, highlighted<br />

in blue. Once you double-click this option, NetBeans will write this method structure for you:<br />

@Override<br />

public void handle (long now) {<br />

throw new UnsupportedOperationException("Not supported yet.");<br />

}<br />

150<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!