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 11 ■ Moving Your Action Figure in 2D: Controlling the X and Y Display Screen Coordinates<br />

Figure 11-14. After the four if statements, add statements calling the .setTranslate() methods off of the spriteFrame<br />

As you can see in Figure 11-14, the code is error- and warning-free, and we’re ready to test the code that we have<br />

written during the chapter, including a reorganized InvinciBagel.java class and its six new methods, the updated<br />

Bagel.java class and its .update() method, and the updated GamePlayLoop.java class, and its .handle() method.<br />

Testing Our New Game Design: Moving InvinciBagel<br />

We have made significant changes to our game application during this chapter, especially to the structure of the<br />

InvinciBagel.java class, adding six all-new methods, and moving our event handling code around completely. We<br />

created an iBagel Bagel object, and a castDirector CastingDirector object, using classes that we created in Chapter 10. We<br />

wired up our GamePlayLoop object and one of our Actor objects (an iBagel Bagel object) by using the <strong>Java</strong>FX pulse<br />

engine .handle() method in the GamePlayLoop.java class and the .update() method in the Bagel.java class. Now the<br />

time has come to use our Run ➤ Project work process and make sure that all of the <strong>Java</strong> code that we have put into<br />

place during this chapter does what it is supposed to do: that is, what we think that it should do. After all, that is what<br />

the programming practice is all about: writing code that we think will do something, running it to see if it does, and<br />

then debugging it to find out why it is not working, if in fact it is not. Once you click on the Play button at the top of the<br />

NetBeans IDE and invoke the Run ➤ Project process, the code will compile and the InvinciBagel game window seen<br />

in Figure 11-15 will open up on your desktop. The first thing that you should notice is that the InvinciBagel sprite is<br />

nowhere to be seen, since we added it to the root StackPane object first instead of last, and so the splashscreen and<br />

game user interface design is still working as intended.<br />

246<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!