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


The next thing that we need to do is to put the Java code into place that will hide the Score UI pane on
the startup of the game in the same way that it is for the Q&A UI panel. Your new start() method code should
look like the following code, shown in Figure 22-9, once you add your scoreLayout.setVisible(false);
Java statement:


public void start() {
loadImageAssets();
loadAudioAssets();
createSpecialEffects();
createTextAssets();
createMaterials();
createBoardGameNodes();
createUInodes();
createQAnodes();
qaLayout.setVisible(false);
createScoreNodes();
scoreLayout.setVisible(false);
...
}


As you can see in Figure 22-10, you still need to set your scoreLayout StackPane to be visible at the
end of your cameraAnimIn Animation object animation by using your .setOnFinished(event) event
handling infrastructure. This code is already in place because we are already revealing the Q&A UI panel
after the camera animation has been completed. Therefore, all we have to do is to add the scoreLayout.
setVisible(true); statement at the end of the cameraAnimIn.setOnFinished(event->{}); structure,
which is shown highlighted in light blue and yellow in the middle of Figure 22-10. You must put this Java 9
code into place before you will be able to test your Score UI panel.


Figure 22-9. Add the .setVisible(false) method call off scoreLayout after the createScoreNodes() method to
hide the panel on startup

Free download pdf