Game Development Reference
In-Depth Information
The next step in the work process is to “wire” the scoreText Text object into the
scoreFont Font object using the .setFont() method, which is called off of the scoreText
object and sets the Text object to utilize the scoreFont Font object using the following
code, which is shown in the bottom part of Figure 17-5 . You can also use a .setFill()
method called off of the scoreText Text object to set the color of the Text object; for
now, we will use a Color.BLACK constant.
scoreText .setFont (scoreFont);
scoreText .setFill (Color.BLACK);
Now we can test the scoreText Text object placement, and refine our X,Y screen
location values, so that the score is right next to the HBox UI Button bank. I found that
I had to move the Y location down twenty pixels to a pixel location of 385, while I had
to move the X location five pixels to the right, to a pixel location of 445, as is shown in
Figure 17-6 , in the left half of the screen shot, in the bottom right of the InvinciBagel
game, next to the Legal Button.
Figure 17-6 . Test the scoreText and scoreFont objects using the Run
Project work process to refine their place-
ment
We will be adding a Text object label that says “SCORE:” in the next section of the
chapter to label our score for the player. The result of this second round of coding is
shown in the right half of Figure 17-6 , at the bottom right.
CreatingaSCORELabel:AddingtheSecondTextOb-
ject
 
 
Search WWH ::




Custom Search