Game Development Reference
In-Depth Information
If you wanted to add a black background to the scene, you would select the fifth
overloaded constructor method, using a Color.BLACK constant from the Color class
(this is a Paint object, because Color is a Paint subclass) as your fill data (in this case,
a fill Color). You would do this by using the following Scene() object constructor
method call:
Scene scene = new Scene(root, 300, 250, Color.BLACK );
Note that the root object is a Parent subclass, called the StackPane class, created
using the StackPane() constructor method (two lines above the Scene() constructor
method call) by using the following line of Java code:
StackPane root = new StackPane(); // StackPane
subclassed from Parent, so Parent root satisfied
As you can see, any class can be used in the constructor that is a subclass of the ob-
ject (class) type that is declared (required) for that constructor parameter position
(data). You are able to use Color and StackPane objects in your parameter list because
they have superclass origins from the Paint and Parent classes, respectively.
In case you are wondering, the Boolean depthBuffer parameter is used for 3D
scene components. Because these scene components are 3D and have depth (a z com-
ponent, in addition to 2D x and y components), you will need to include this parameter,
and set it to a value of true , if you are creating 3D scenes or combining 2D and 3D
scene components. Finally, the SceneAntialiasing object (and class) that is passed in
the parameter list for the fourth constructor method provides real-time smoothing for
3D scene components.
JavaFXSceneGraph:OrganizingScenes,UsingParent
Nodes
A scene graph, which is not unique to JavaFX and which can be seen in quite a few
new media content creation software packages, is a data structure that resembles an
upside-down tree, with the root node at the top and branch nodes and leaf nodes
coming off the root node. The first time I saw a scene graph approach to design was
when I was 3D modeling using a software package on the Amiga called Real 3D from
Realsoft Oy. This approach has been copied by many 3D, digital video, and digital
imaging software packages since then and now is a part of how JavaFX organizes con-
Search WWH ::




Custom Search