Game Development Reference
In-Depth Information
Next we covered how to turn Java 7 compatible anonymous inner class event hand-
ling structures into a Java 8 lambda expression using NetBeans. I wanted to cover Java
8
lambda expressions
in this topic, even though they are an advanced feature, because
they are one of the major new features in Java 8, and this is a Java 8 programming title.
Finally we got into adding new features to our Java 8 game programming infra-
structure, and learned about
input event
(InputEvent) classes and subclasses and about
how the event handler (EventHandler) class structures are set up, and how they span
across the java.lang, java.util, javafx.event and javafx.scene.input packages. We took a
look at
KeyCode
constants and at the
KeyEvent
class, and then implemented this
KeyEvent handing in our Java game code, using
.setOnKeyPressed()
and
.setOnKeyReleased()
event handler structures for both Java 7 and Java 8 compatibil-
ity.
In the next chapter, we are going to take a look at how to move a game sprite
around your screen using this KeyEvent event handling structure that we have created
during this chapter, as well as how to ascertain the boundary (edges) of the screen,
character direction, movement velocity, and related animation and movement consider-
ations.