Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 7 ■ IntroduCtIon to JavaFX 9: overvIew oF the JavaFX new MedIa engIne

Scene Graph Architecture classes for JavaFX start at the highest level with the Node superclass, along
with its Parent and SubScene subclasses and the Group subclass of the Parent class, which we will be using
later during this book to create our game Scene Graph hierarchy. These core Node classes are used to create
the game’s JavaFX Scene Graph hierarchy and are used to organize and group objects that have been created
using JavaFX media asset and graphic design packages, which are contained in the javafx.media and javafx.
graphics Java 9 modules.
There are three Scene utility classes, as I call them, which allow you to take a Snapshot (like a
screenshot) of your Scene or any of its Scene Graph nodes at any time, as well as to turn Scene AntiAliasing
on or off, if you are using 3D primitives (geometry defined using math rather than a mesh) in a Scene. The
other half (eight) of the classes in the javafx.scene package are utilized for scene lighting, scene cameras, and
cursor control for your scene.
We’ll be covering these javafx.scene classes in future chapters as we create your game, after we take a
look at the Scene Graph classes that are used to create, group, manage, and manipulate your JavaFX scene
content. Thus, I will be covering the javafx.scene package’s classes, shown in Figure 7-2, from the left side
of the diagram and moving to the right side of the diagram, in the order of the classes that you are likely to
use the most often to those used the least often. That said, all of these classes (with the possible exception of
Snapshot) are very important for i3D games.


JavaFX Scene Class: Defining Dimension and Background Color


The two primary classes in the javafx.scene package are the Scene class and the Node class. We will be
covering the Node class and its Parent, Group, and SubScene subclasses in the next section, as those
classes, along with their subclasses (such as the StackPane class used in the JavaFXGame class), can be
utilized to implement the Scene Graph architecture in JavaFX. Also, in a sense, and in my diagrams shown
in Figure 7-2 and 7-3, the Node class and its subclasses can be viewed as being “below” the Scene class,
although the Node class is not a subclass of the Scene class. In fact, the Node (Scene Graph) class and its
subclasses, or rather the objects created using these classes, are actually contained inside of the Scene
object itself, just like things are grouped by scene in real-life stage productions. For this reason, we will


Figure 7-2. The Java javafx.scene package and 16 core Scene Graph, Scene Utility, Lighting, Camera, and
Cursor classes

Free download pdf