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


As shown highlighted in Figure 22-14, we’ve declared a scoreRight Text object at the top of the class and
also added it to the scoreLayout.addChildren().addAll() method chain so it can be seen in the test render
we’ll be doing.


I added the scoreRight object instantiation after the scoreTitle object and configured it to use the
Dark Blue color, Arial Black font face, at a 72-point font size. I added X and Y coordinates to initially position
it at (-50, 150) within a scoreLayout StackPane. Figure 22-14 shows the code, which looks like the following:


private void createScoreNodes() {
...
scoreTitle = new Text("SCORE");
scoreTitle.setFont( Font.font("Arial Black", 72) );
scoreTitle.setFill(Color.DARKRED);
scoreRight = new Text("Right:");
scoreRight.setFont( Font.font("Arial Black", 72 ) );
scoreRight.setFill(Color.DARKBLUE);
scoreRight.setTranslateX(-50);
scoreRight.setTranslateY( 150 );
}


Figure 22-14. Add a scoreRight object at the top of the class, instantiate and configure it, and add it to the
SceneGraph

Free download pdf