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

Then you’ll have all your answers and scoring in place! You can start “error proofing” your code in the
next chapter to ensure that multiple UI elements cannot be clicked before they’re needed. Remember, these
are young children, and intellectually challenged, playing an educational game, so you’ll need this user
interface protection. The Java code for the scoreLayout.getChildren().addAll() method chain looks like
the following Java code, shown in Figure 22-31:


scoreLayout.getChildren().addAll( scoreTitle, scoreRight, scoreWrong, scoreCheer,
rightAnswers, wrongAnswers);


Figure 22-32 shows the Run (^) ➤ Project work process used to render the new wrongAnswers Text object and
its settings; as you can see, this aligns the score (integer) elements and leaves room for larger scores (10s and 100s)
if the numeric fields expand to the right, which we’ll be ascertaining in the next section on score code testing.
Figure 22-32. Use your Run ➤ Project work process to preview your Score UI panel and your wrongAnswers
Text object
Figure 22-31. Be sure to add any new Node objects to the SceneGraph hierarchy so they will be visible at
render time

Free download pdf