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 don’t want this Button visible until after a player has selected their answer, we set againButton
to be invisible on startup. To do this we use a .setVisible(false) method call off againButton in the top of the
start() method after the createBoardGameNodes() method call. This looks like the following code, which is
shown highlighted in Figure 23-19:


againButton.setVisible(false);


Next, add the againButton.setVisible(true); Java statement to the end of each Button.setOnAction()
construct to turn on the Let’s Play Again Button visibility, as shown highlighted in yellow and blue in
Figure 23-20.


Figure 23-19. Set your againButton visibility to false in the start() method, after the createBoardGameNodes()
method


Figure 23-20. Call againButton.setVisible(true); at end of each answer Button event handler, after
buttonClick = false;

Free download pdf