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

Increment the .setTranslateX() method call for the rightAnswers and wrongAnswers Text objects from
96 to 120. This will center the numeric part of the Score UI between the label (heading) and the right side
of the Score UI panel. Your code should now look like the following, which is highlighted in the middle and
bottom of Figure 22-34:


rightAnswers = new Text("0");
rightAnswers.setFont(Font.font("Arial Black", 64));
rightAnswers.setFill(Color.BLACK);
rightAnswers.setTranslateX( 120 ); // Update X position 24 units from 96 to 120
rightAnswers.setTranslateY(160);
wrongAnswers = new Text("0");
wrongAnswers.setFont(Font.font("Arial Black", 64));
wrongAnswers.setFill(Color.BLACK);
wrongAnswers.setTranslateX( 120 ); // Update X position 24 units from 96 to 120
wrongAnswers.setTranslateY(160);


Figure 22-34. Expand the X position of each numeric element 24 units to the right, from a value of 96 to a
value of 120

Free download pdf