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 easiest way to fix this glitch is to simply hide the UI panel (since we are hiding it on game startup anyway)
automatically on game startup, rather than manually using a Start Game Button UI element. This is done at
the top of your start() method, required by JavaFX, rather than in an event handling structure connected to an
initial click on a Start Game Button UI element.


First, remove the qaLayout.setVisible(false); Java statement from within the gameButton event-
handling code and place it at the top of your .start() method so that this hide gets processed automatically.
Remember that your qaLayout StackPane will get created in the createQAnodes() method, so this
statement will need to come after your createQAnodes(); custom method call and thus after any of the
methods called before this custom method. This is fine, as these simply set up asset references and objects
that will be used in your game.
This ends up being a quicker and easier fix to this visual bug; since we are already going to hide this
panel on game startup, doing this hide (set visibility false) earlier on (automatically) rather than in the event
handling logic both creates cleaner code and saves us the time figuring out why (clearly a Z unit setting
problem in 3D space) this is happening and how to add (and adjust) Z location code for the qaLayout
StackPane object that will not mess up your currently pristine results (other than on this initial SplashScreen
display).


Figure 22-1. Let’s fix the Q&A Button pane rendering bug that affects the startup screen first before developing
the scoring

Free download pdf