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


A Method for Loading Image Assets: .loadImageAssets()


Open your empty loadImageAssets() method structure to add five Image() constructor methods,
instantiating and loading your Image objects with the correct image asset and its specifications, as shown
highlighted in Figure 9-7.


The Java code, shown in Figure 9-7, should look like this:

splashScreen = new Image("/welcome.png", 1280, 640, true, false, true);
helpLayer = new Image("/instructions.png", 1280, 640, true, false, true);
legalLayer = new Image("/copyrights.png", 1280, 640, true, false, true);
creditLayer = new Image("/credits.png", 1280, 640, true, false, true);
scoreLayer = new Image("/highscores.png", 1280, 640, true, false, true);


Figure 9-7. Instantiate and reference your five Image objects inside of the loadImageAssets() method you just
created


Figure 9-6. Copy the PNG32 files for the digital image titles for the UI screens to /NetBeansProjects/
JavaFXGame/src/

Free download pdf