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

What this constructor method format does is to load the Image with the digital image asset in your JAR
file, referenced using the “root” or forward slash character, since the file is in the /src/ folder. The second
and third entries represent the image X and Y resolution, and the fourth true entry turns on aspect ratio
locking. The fifth false entry turns off bilinear interpolation, and a sixth true entry turns on background
image loading, as a speed optimization.


A Method for Creating Text Assets: .createTextAssets()


Open your empty createTextAssets() method structure and add eight Text() constructor methods,
instantiating and loading your Text objects with correct information. The code, shown in Figure 9-8, should
look something like this:


playText = new Text("Press the Start Game Button to Start! \n");
moreText = new Text("Use other buttons for instructions, copyrights, credits and high scores.");
helpText = new Text("To play game roll dice, advance gamepiece, follow gameboard instruction.");
cardText = new Text("If you land on square that requires card draw it will appear in UI area.");
copyText = new Text("Copyright 2015 Wallace Jackson, All Rights Reserved. \n");
riteText = new Text("Visit the iTVboardGame.com website on the Internet: http://www.iTVboardgame.com");;)
credText = new Text("Digital Imaging, 3D Modeling, 3D Texture Mapping, by Wallace Jackson. \n");
codeText = new Text("Game Design, User Interface Design, Java Programming by Wallace Jackson.");


Figure 9-8. Declare eight Text objects at top of class; instantiate and load Text objects in the createTextAssets()
method

Free download pdf