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


Next, let’s test the scoring code that we just wrote and see whether the Score UI design responds
correctly to the increment of the score into double digits. That is, does an increase in numeric value expand
to the right or to the left? Or does it expand from the center? Once we figure this out, we can further “tweak”
(optimize) our Scoring UI design.


Score UI Testing: Displaying Higher Integer Numbers


Since we have not implemented “player proofing” Java code, which we are going to do in the next chapter
so that the player cannot click a UI element (3D spinner, game board square, Button) more than one time in
each gameplay cycle to “game” the system (or cause rendering errors to surface), we can currently click the
Button elements more than one time. This allows us to test the scoreboard UI to find out how numbers larger
than 9 will be displayed so that we can “tweak” the X location and space the numbers (right and wrong)
either to the left (current spacing), to the far right, or in the center of the label (heading) and the right edge of
the score UI panel. As you can see in Figure 22-33, I have clicked the correct (Falcon Hawk) answer ten times
to see how the number will move. As you can see, the number expands out from the center, which you can
see by comparing the 10 to the 2, rather than to the left or right. Therefore, we need to move these 120 units
to the right. Now your score values will be able to expand to two or three digits.


Figure 22-33. Use your Run ➤ Project work process and click the Button elements to increment (test) your
scoring code

Free download pdf