Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 14 ■ 3D MoDel hierarChy Creation: Using priMitives to Create a gaMe BoarD


of this game board. To get NetBeans 9 to create this new method for you, add a line of code after the
createBoardGameNodes() method call, in the first portion of your start() method, and then type in the
following Java method call, naming your new method:


createGameBoardNodes();


NetBeans will realize this is not a valid method call and will highlight it by using a wavy red underline.
Use your Alt+Enter work process, and double-click your Create method “createGameBoardNodes()”
in javafxgame.JavaFXGame option, highlighted in Figure 14-1, to have NetBeans create an empty method
body structure for you. Next, remove the box Box object–related code from createBoardGameNodes() and
place this code in this new method. We’ll also remove the pole Cylinder and sphere Sphere so they don’t
interfere with your game board design.


Cut and paste your Box primitive code from .createBoardGameNodes() to .createGameBoardNodes()
and rename the box to Q1S1. Delete all the Java statements, except an instantiation and shader method call,
as shown in Figure 14-2:


Q1S1 = new Box(150, 5, 150);
Q1S1.setMaterial(phongMaterial);


Figure 14-1. Open the start() method; type a createGameBoardNodes() method call after
createBoardGameNodes()

Free download pdf