Game Development Reference
In-Depth Information
which now that our hero is in place, could be game props, projectiles, enemies, treas-
ure, and so on.
Update Splashscreen Scene Graph: .createS-
plashScreenNodes()
Now the time has come to reorganize our .createSplashScreenNodes() method body,
and then we will be ready to get into “wiring up” the JavaFX pulse engine that we cre-
ated in our GamePlayLoop.java class to the Actor object that we created using our Act-
or.java, Hero.java and Bagel.java classes. We have already removed four lines of code
from the end of the .createSplashScreenNodes() method, and placed them into the
.loadImageAssets() method, where they more logically belong. The other thing that we
need to do to try and streamline our .start() method is to group the ActionEvent hand-
ling structures with each of their respective object instantiations and configuration Java
statements. Thus, your gameButton object instantiation, configuration, and event
handling will all be kept together in one place, for instance. We will do the same thing
for the helpButton , scoreButton , and legalButton objects. The event handling struc-
tures that I copied from the .start() method into the .createSplashScreenNodes() method
are shown here in bold. The new .createSplashScreenNodes() method body will contain
the following three dozen lines of Java code:
private void createSplashScreenNodes() {
buttonContainer = new HBox(12);
buttonContainer.setAlignment(Pos.BOTTOM_LEFT);
buttonContainerPadding = new Insets(0, 0, 10, 16);
buttonContainer.setPadding(buttonContainerPadding);
gameButton = new Button();
gameButton.setText("PLAY GAME");
gameButton.setOnAction((ActionEvent) -> {
splashScreenBackplate.setVisible(false);
splashScreenTextArea.setVisible(false);
});
helpButton = new Button();
helpButton.setText("INSTRUCTIONS");
helpButton.setOnAction((ActionEvent) -> {
splashScreenBackplate.setVisible(true);
splashScreenTextArea.setVisible(true);
Search WWH ::




Custom Search