Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 9 ■ JavaFX 9 User InterFaCe DesIgn: the Front enD For Java 9 game DesIgn

In the beginning of the loadImageAssets() method, instantiate the backPlate and alphaLogo Image
objects and then load them with their associated digital image assets using the following Java code, as shown
in Figure 9-12:


backPlate = new Image("/backplate8.png", 1280, 640, true, false, true);
alphaLogo = new Image("/alphalogo.png", 1200, 132, true, false, true);


At the end of this same loadImageAssets() method, instantiate your uiBackgroundImage object and
load it with the backplate Image object, which we will use as an optimized, 8-bit PNG8 background image
for the composite splash screen image we’re creating using Node subclasses (StackPane, ImageView, and
VBox); you can do this using the following Java code, also shown in Figure 9-12:


uiBackgroundImage = new BackgroundImage(backPlate,
BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT,
BackgroundPosition.CENTER, BackgroundSize.DEFAULT);


Finally, you will need to instantiate the uiBackground Background object and, using its constructor
method, load it with the uiBackgroundImage BackgroundImage object you just created in the previous
line of Java code. This would be done using the following line of code, shown highlighted in the
loadImageAssets() method in Figure 9-12:


uiBackground = new Background(uiBackgroundImage);


Figure 9-12. Add a backgroundImage object named uiBackgroundImage; use the .setBackground() method
to load it

Free download pdf