Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 23 ■ Completing the gameplay Code and player proofing your event handling

Since we only estimated the location and size of the Button in Figure 23-18, let’s use the Run ➤ Project
work process so we can see whether the Button UI element is centered over the four-color intersection of
the game board design. As you’ll see in Figure 23-21, we have some tweaking to do, as the Button is over the
quadrant image for the content.


Also notice that we need to set a Yellow background color for the Button since the quadrants use
pink, blue, green, and orange. Add in the .setBackground(new Background(new BackgroundFill(color.
YELLOW))) method chain to set a Yellow color value (don’t forget the empty CornerRadii and Insets), as
shown highlighted in blue in Figure 23-22. Increase your .setMinSize() to 300, 200; increase your font size to
35 ; and reposition X, Y, Z to (190, -580, 100).


Figure 23-21. Use the Run ➤ Project work process to test the againButton code to see whether it is located and
sized properly


Figure 23-22. Add a Yellow background color and adjust the translate values and size values to center the
againButton

Free download pdf