Game Development Reference
In-Depth Information
Figure 17-26 . Install the skyCloud background Image (left), and use a .toBack() method call to set proper z-index
(right)
Since we want to have our background image at the lowest (zero) z-index so it will
be behind all of our game play assets, but also have all the splashscreen assets at the
highest z-index, so that those image plates will cover (be in front of) all of our game
play assets, we normally would have to implement yet another ImageView compositing
plate, to be able to do this. However, there is a handy set of z-index related Node class
methods that will allow us to use the SplashScreenBackplate ImageView object to hold
both the game splashscreen and a game background image plate at the same time! This
is one of the ImageView Node optimizations that I wanted to implement to keep our
game Nodes at a minimum, to reduce memory and processing overhead. The code to
place the ImageView behind our game assets will call the .toBack() method off of the
SplashScreenBackplate ImageView Node object, which relocates that Node to the
Back (Bottom layer) of the JavaFX Scene Graph Node Stack. This is the equivalent of
setting this Node's z-index to zero . The Java statement can be seen highlighted in light
blue at the top of Figure 17-26 , and the completed Java code for your
gameButton.setOnAction((ActionEvent)->{} event handling structure
should look like the following:
gameButton.setOnAction((ActionEvent) -> {
splashScreenBackplate.setImage( skyCloud );
splashScreenBackplate.setVisible( true );
splashScreenBackplate .toBack() ;
splashScreenTextArea.setVisible( false );
});
 
Search WWH ::




Custom Search