Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 22 ■ SCoring engine: Creating the SCore Ui LayoUt and SCoring the Content


You’ll leave the other four copied Java statements the same (other than changing qaLayout to
scoreLayout), as other than the X location, you want to “mirror” the height, depth, background color, and
preferred StackPane size. Add this scoreLayout to the SceneGraph using the following Java code, which is
also shown highlighted in Figure 22-6:


private void addNodesToSceneGraph() {
root.getChildren().addAll(gameBoard, uiLayout, qaLayout, scoreLayout, spinner);
...
}


Let’s again use the Run (^) ➤ Project work process and test this new code for your Score UI panel to make
sure that is mirroring the Score UI panel design far enough to the right of the screen using a .setTranslateX()
method call value. As you can see in Figure 22-7, we’re falling about 400 units short of the right corner of the
game with our guess. Therefore, we’ll need to change the 250 value to a 650 value to move this StackPane
container further to the right, as well as to prevent this 2D StackPane UI container object from intersecting
with your i3D game board Node hierarchy.
Figure 22-6. To render the scoreLayout StackPane, you must first add it to the root.getChildren().addAll()
method chain

Free download pdf