Game Development Reference
In-Depth Information
Figure 6-8 . Coding the addNodesToStackPane() method, using the .getChildren() method chained to the .add() meth-
od
The important thing to note here is the order in which the Node objects were added
to the StackPane root Scene Graph object. This affects the compositing layer order for
the image compositing, as well as for the UI element compositing, on top of these di-
gital image elements. The first node added to the StackPane will be on the bottom of
the layer stack; this needs to be the splashScreenBackplate ImageView Node object,
as you can see in the figure.
The next node to add will be the splashScreenTextArea ImageView Node object,
as the transparent images with the panel overlays need to go right on top of Pat Har-
rington's InvinciBagel splash screen 2D artwork. After this, you can place the UI
design, which, in this case can be done in one fell swoop, using the buttonContainer
HBox Node object, which contains all the Button objects. Note that you do not have to
add buttons to this StackPane root Scene Graph object, because you have already used
the .getChildren().addAll() method chain to add your Button UI controls to the Scene
Graph hierarchy below an HBox (Parent object) Node branch object. Now, you are
ready to test!
Testing the InvinciBagel Application:
Pulse the Scene Graph
Click the green Play arrow at the top of the NetBeans IDE, and run the project . This
will bring up the window illustrated in Figure 6-9 (I have removed the Java code added
in Chapter 4 , demonstrating how to create a windowless application). So, you have
window “chrome” back, at least for now. As you can see, you are getting a very good
result, using only a dozen import statements (external classes), a few dozen lines of
Java code, and a half a dozen child nodes below the Scene Graph root (StackPane) ob-
ject. As you can see, JavaFX does a great job of compositing the backplate, composite
image overlays, and button bank overlay into one seamless, professional result!
 
Search WWH ::




Custom Search