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 4 ■ An Introduction to <strong>Java</strong>FX 8: Exploring the Capabilities of the <strong>Java</strong> 8 Multimedia Engine<br />

Figure 4-2. The javafx.scene package and its 16-core Scene Graph, Scene utility, Lighting, Camera, and Cursor classes<br />

I have grouped these 16 javafx.scene package classes logically. The Scene class is inside the Scene Graph section<br />

of the diagram, because Scene objects, which are created using the Scene class, contain Scene Graph objects, which<br />

are created using these four Scene Graph–related classes (Node, Parent, Group, SubScene) and their subclasses. I will<br />

be covering the Scene Graph classes in detail later in the chapter (see the section “<strong>Java</strong>FX Scene Graph: Organizing<br />

Scenes, Using Parent Nodes.”<br />

Scene Graph architecting classes in <strong>Java</strong>FX start at the highest level, with a Node superclass, and its Parent class,<br />

and include the Group and SubScene classes, which are subclasses of the Parent class. These core classes are used<br />

to create the <strong>Java</strong>FX Scene Graph hierarchy and to organize and group objects that have been created using the other<br />

<strong>Java</strong>FX classes in the <strong>Java</strong>FX packages.<br />

There are three Scene utility classes, as I call them, which allow you to take a snapshot (like a screenshot) of<br />

your scene or any of its Scene Graph nodes at any time as well as to turn SceneAntialiasing on and off if you are using<br />

3D primitives in a scene. The other half (eight) of the classes in the javafx.scene package are used for scene lighting,<br />

scene cameras, and cursor control for your scene. I will be discussing these classes later in the chapter (see the section<br />

“<strong>Java</strong>Fx Scene Content: Lights, Camera, Cursor, Action!”), after you take a look at the Scene Graph classes, which<br />

create, group, manage, and manipulate your <strong>Java</strong>FX scene content. Thus, I will be covering the javafx.scene package<br />

classes shown in the figure, from the left-hand side of the diagram to the right-hand side, in the order in which you are<br />

most likely to use them, from least to most.<br />

<strong>Java</strong>FX Scene Class: Scene Size and Color and Scene Graph Nodes<br />

The two primary classes in the javafx.scene package are the Scene class and the Node class. I will be covering the<br />

Node class and its Parent, Group, and SubScene subclasses in the next section, as those classes, along with their<br />

subclasses (such as the StackPane class used in the InvinciBagel class) are used to implement the Scene Graph<br />

architecture in <strong>Java</strong>FX. Also, in a sense (and in my diagram) the Node class and its subclasses can be viewed as being<br />

below the Scene class, although the Node class is not a subclass of the Scene class. In fact, the Node (Scene Graph)<br />

class and subclasses, or rather the objects created using these classes, are contained inside the Scene object itself.<br />

For this reason, you will first consider how the Scene class, and its Scene() constructor method, is used to create<br />

Scene objects for <strong>Java</strong>FX applications. This section will provide reinforcement of what you learned in Chapter 3<br />

regarding overloading constructor methods, as there needs to be several different ways to create a Scene object.<br />

78<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!