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


Now we can “decorate” the interior of the scoreLayout StackPane using Text objects of different colors,
which we can use to label the sections of our Score UI panel using a nice large font and dark primary (RGB)
color values.


Adding Your Score UI Container Design Elements: Text Objects


Add the scoreTitle Text object to the Text compound statement at the top of your class and then add
scoreTitle to a scoreLayout.addChildren().addAll() method chain in your addNodesToSceneGraph()
method, as shown in Figure 22-12. The Java code should look like the following, which is also shown in
yellow at the top of Figure 22-12:


private void addNodesToSceneGraph() {
root.getChildren().addAll(gameBoard, uiLayout, qaLayout, scoreLayout, spinner);
gameBoard.getChildren().addAll(Q1, Q2, Q3, Q4);
Q1.getChildren().addAll(q1, Q1S1, Q1S2, Q1S3, Q1S4, Q1S5);
Q2.getChildren().addAll(q2, Q2S1, Q2S2, Q2S3, Q2S4, Q2S5);
Q3.getChildren().addAll(q3, Q3S1, Q3S2, Q3S3, Q3S4, Q3S5);
Q4.getChildren().addAll(q4, Q4S1, Q4S2, Q4S3, Q4S4, Q4S5);
qaLayout.getChildren().addAll(a1Button, a2Button, a3Button, a4Button);
scoreLayout.getChildren().addAll(scoreTitle);
uiLayout.getChildren().addAll(boardGameBackPlate, logoLayer, infoOverlay, uiContainer);
uiContainer.getChildren().addAll(gameButton, helpButton, legalButton, creditButton,
scoreButton);
infoOverlay.getChildren()addAll(platText, moreText);
}


Figure 22-12. Add a scoreTitle Text object, instantiate it, and configure it in createScoreNodes(). Then add it
to the SceneGraph

Free download pdf