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


Next, let’s go into the gameButton event handling code block and remove the .setFieldOfView(1)
method call simply by commenting out that line of code, which as you can see is a slick and common code
debugging trick.
We will do this because that particular method call is not supported for the new ParallelCamera object.
We will also change the camera.setTranslateZ() method call to the diagonal value for the game board that I
calculated to place the camera view at game board center ( 625 ).
I will also set the camera.setTranslateX() method call to be one-quarter of the game board width of 225 ,
as shown in the highlighted camera object code in the middle of Figure 14-28.


Figure 14-27. Change the Scene camera object to use a ParallelCamera class (algorithm) instead of
PerspectiveCamera


Figure 14-28. Remove the FOV setting code, change .setTranslateX() to 225, .setTranslateZ() to 625, and Y = 0

Free download pdf