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

}<br />

scene.setOnKeyReleased((KeyEvent event) -> {<br />

switch (event.getCode()) {<br />

case UP: up = false; break;<br />

case DOWN: down = false; break;<br />

}<br />

});<br />

case LEFT: left = false; break;<br />

case RIGHT: right = false; break;<br />

case W: up = false; break;<br />

case S: down = false; break;<br />

case A: left = false; break;<br />

case D: right = false; break;<br />

Figure 11-2. Create private void createSceneEventHandling() method for OnKeyReleased and OnKeyPressed event<br />

handling structures<br />

Now that the event handling for the game play is where it needs to be, before we can write the rest of the method<br />

structures for adding Image, Actor, and CastingDirector objects, we’ll need to declare these objects for use at the top of<br />

our InvinciBagel.java class. Let’s do this work that sets up the rest of the methods we’ll need to code next.<br />

232<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!