Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 12 ■ 3D MoDel Design anD priMitives: Using JavaFX 9 shape3D Classes


If you used your Run ➤ Project work process at this point, you would not see the pole object, as
you have not added it to the JavaFX SceneGraph yet. Open the addNodesToSceneGraph() method and
add the pole object to the end of the Java List contained inside of the parameter area (parens). This is all
accomplished using the following Java code structure inside the .handle() method, as is shown highlighted
in the middle of Figure 12-5:


gameBoard.getChildren().addAll(sphere, box, pole); // in addNodesToSceneGraph() method


Figure 12-5. Add a pole Cylinder object to SceneGraph, at the end of the gameBoard.getChildren().addAll()
method call


Figure 12-4. Create a Cylinder object named pole and instantiate it with a radius of 50, a height of 250, and
24 divisions

Free download pdf