Game Development Reference
In-Depth Information
splashScreenTextArea.setImage(instructionLayer);
});
scoreButton = new Button();
scoreButton.setText("HIGH SCORES");
scoreButton.setOnAction((ActionEvent) -> {
splashScreenBackplate.setVisible(true);
splashScreenTextArea.setVisible(true);
splashScreenTextArea.setImage(scoresLayer);
});
legalButton = new Button();
legalButton.setText("LEGAL & CREDITS");
legalButton.setOnAction((ActionEvent) -> {
splashScreenBackplate.setVisible(true);
splashScreenTextArea.setVisible(true);
splashScreenTextArea.setImage(legalLayer);
});
buttonContainer.getChildren().addAll(gameButton,
helpButton, scoreButton, legalButton);
splashScreenBackplate = new ImageView();
splashScreenBackplate.setImage( splashScreen );
splashScreenTextArea = new ImageView();
splashScreenTextArea.setImage( instructionLayer );
}
Notice that since the .loadImageAssets() method is called before the .createS-
plashScreenNodes() method, that we can still keep the last four lines of code in the
method body that reference the loaded Image assets in place. This is because the
splashScreen and instructionLayer Image objects have been created, and loaded with
their digital image assets, in the top part of the .loadImageAssets() method. Since this
method is called inside the .start() method before the .createSplashScreenNodes()
method is called, these objects can be safely used inside of this method body.
As you can see in Figure 11-10 , the new method is error-free and all of the objects,
including the HBox named buttonContainer, Button(s) named gameButton, helpButton,
scoreButton and legalButton, and ImageView(s) named splashScreenBackplate and
splashScreenTextArea, are all logically grouped together, and are now well organized.
 
Search WWH ::




Custom Search