Game Development Reference
In-Depth Information
cause the buttons are inside the HBox, this is just for visual organization, not to make
the code work) and then copy and paste them three more times, on separate lines. This
will allow you to change the game to help, score, and legal, respectively, by creating
the following four button Java codes:
gameButton = new Button();
gameButton.setText("PLAY GAME");
helpButton = new Button();
helpButton.setText("INSTRUCTIONS");
scoreButton = new Button();
scoreButton.setText("HIGH SCORES");
legalButton = new Button();
legalButton.setText("LEGAL & CREDITS");
Now that you have created the HBox Button UI control layout container and but-
tons, you still need to write one more line of code to fill the HBox with Button objects,
using the .getChildren().addAll() method chain, like this:
buttonContainer. getChildren (). addAll (gameButton,
helpButton, scoreButton, legalButton);
Next, let's add your image-compositing Node objects (Image and ImageView) so
that you can add the artwork for your InvinciBagel splash screen as well as the panel
overlays that will decorate your instructions, legal disclaimers and production credits
and a background and screen title for your (eventual) game high scores table. I use two
ImageView objects to contain these two layers; let's set up the bottommost backplate
image layer first by using the following Java code to instantiate the Image object and
then the ImageView object and wire them together:
splashScreen = new Image("/invincibagelsplash.png", 640,
400, true, false, true);
splashScreenBackplate = new ImageView();
splashScreenBackplate.setImage(splashScreen);
// this
Java statement connects the two objects
Finally, let's do the same thing for the image-compositing plate, that is, the
ImageView that will hold the different Image objects containing the alpha channel
(transparency) values that will create an overlay of panel images for the InvinciBagel
splash screen artwork (which was created by the talented 2D artist Patrick Harrington):
Search WWH ::




Custom Search