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


The only thing that we have left to do is to finish implementing the Image objects for the other four
sections and implement font style and color in the other four TextFlow objects. All of these objects will be
called in your event-handling code, which we’ll be adding in Chapter 10 (which covers event handling and
effects in JavaFX 9 and Java 9 games).
After all of this 2D screen design and UI design and event handling has been coded, we can start getting
into 3D and i3D during the second half of the book.


Finishing Up Your UI Design Object Creation and Configuration


Let’s open your createTextAssets() method and add the .setFill() and .setFont() method calls off of the other
six Text objects to set their color to match the boardGameBackPlate ImageView that holds the handwriting
text images and to set their Font style to Helvetica Regular. This is a relatively straightforward exercise; the
resulting method body is shown in Figure 9-23 and should look like the following Java method body and Java
statements:


private void createTextAssets(){
playText = new Text("Press the PLAY GAME Button to Start!\n");
playText.setFill(Color.WHITE);
playText.setFont(Font.font("Helvetica", FontPosture.REGULAR, 50));
moreText = new Text("Use other buttons for instructions,\ncopyrights, credits and
scores.");
moreText.setFill(Color.WHITE);
moreText.setFont(Font.font("Helvetica", FontPosture.ITALIC, 50));
helpText = new Text("To play game roll the dice, advance\ngame piece and
follow game board\ninstructions. ");
helpText.setFill(Color.GREEN);


Figure 9-22. Run the project to make sure the OS chrome has been replaced and the window title is in place
and correct

Free download pdf