Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 9 ■ JavaFX 9 User InterFaCe DesIgn: the Front enD For Java 9 game DesIgn


X translation value of -75 pixels. The new logoLayer ImageView object instantiation, asset referencing, and
transformation (location/translation and scale) configuration code can be seen highlighted in the middle of
Figure 9-18 and should look like this following Java 9 code statement block:


logoLayer = new ImageView();
logoLayer.setImage(alphaLogo);
logoLayer.setScaleX(0.8);
logoLayer.setScaleY(0.8);
logoLayer.setTranslateX(-75);
logoLayer.setTranslateY(-225);


Next, you’ll have to add this new logoLayer ImageView to the StackPane uiLayout container of
compositing layers in your addNodesToSceneGraph() method. While we’re there, since we are adding
multiple Node subclasses to the root and uiLayout SceneGraph hierarchy, we’ll switch from using the
.getChildren().add() method chain to using a .getChildren().addAll() method chain to reduce the number of
Java statements in this method from eight to four.
The order added affects the compositing layer order, so for .add() statements, this equates to top
to bottom. The first statements added (top) are on the bottom of the compositing layer stack (sort of
counterintuitive, isn’t it?).


Figure 9-18. Create a logoLayer ImageView referencing the alphaLogo image; set scale to 80 percent and
position to -75,-225

Free download pdf