Game Development Reference
In-Depth Information
cus on the javafx.scene.input package for the rest of this chapter, as you have already
learned how to use the EventHandler<ActionEvent> {…} structure for Java 7 and the
(ActionEvent) -> {…} structure for Java 8, so it is time to learn how to use other types
of events, called input events , in our Java 8 game development work process.
Let's take a look next at this important JavaFX Scene input event package, and the
twenty-five input event classes that it provides us to use for our Java 8 game develop-
ment.
JavaFX Input Event Classes: The javafx.scene.input
Package
Even though it is the java.util and javafx.event packages that contain the core
EventObject , Event and EventHandler classes that “handle” the events, at the found-
ational level of making sure that the events get processed (handled), there is another
JavaFX package called javafx.scene.input which contains the classes that we will be
interested in using to process (handle) our player's input for the different types of
games that you might be creating. I will call these “input events,” because they are dif-
ferent events than the action events and pulse (timing) events that we have encountered
thus far in the topic. Once we've covered input events in this chapter, you will be fa-
miliar with many of the different types of events that you will want to use in your own
Java 8 games development. Later on in the chapter we will also implement a KeyEvent
object to handle arrow keypad (or DPAD and game controller) usage in our game.
It's interesting to note that a number of the input event types that are supported in
the javafx.scene.input package are more suited to consumer electronics (the industry
term is “embedded”) devices, such as smartphones or tablets, which tells me that
JavaFX is being positioned (designed) for use on open source platforms such as
Android or Chrome. JavaFX has specialized events such as GestureEvent ,
SwipeEvent , TouchEvent , and ZoomEvent , that support specific features in the new
embedded devices marketplace. These input event classes support advanced touch-
screen device features, such as gestures, page swiping, touchscreen input handling, and
multi-touch display that are required features for these devices, which support ad-
vanced input paradigms such as two-finger (pinching in or spreading out) touch input,
for instance, to zoom in and out of the content on the screen.
We will be covering the more “universal” input types in this topic, which are sup-
ported across both personal computers (desktops, laptops, notebooks, netbooks, and the
newer “pro” tablets, such as the Surface Pro 3) as well as embedded devices, including
smartphones, tablets, e-Readers, iTV sets, game consoles, home media centers, Set-Top
Search WWH ::




Custom Search