Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 20 ■ Coding gameplay: Set Up gameplay methodS and animated Camera View

Figure 20-19. Use your file management software to view all of the game image (texture map) assets in the
/src folder


We will also be creating our audio assets and learning some digital audio encoding tricks in the next
chapter using a professional digital audio editing and sweetening package, called Audacity 2.1.3, for
Windows, Mac, and Linux.
Next, let’s add some “wow” factor to the game by zooming the camera into the selected gameplay
quadrant.


Camera Animation: Position Game Board After Select


Let’s add some 3D Camera animation next so that after the player clicks the square that they want to use for
their turn, the Camera object moves in and turns down from -30 degrees to -60 degrees, which will make
the quadrant and its image closer (and more parallel) to the camera. This will make the quadrant image
larger for the player and will also give us more room for the 2D overlay panels on the left and right sides of
the screen. These will contain our UI, scoreboard, and answers for the selected game board square visual
content. Most of this will be created in the next couple of chapters, so we are basically finishing the i3D and
UI programming for the exterior (outer game board) parts of the game. In the next chapters, we will start the
interior (Q&A) and audio portions of the game’s programming.
Add a rotCameraDown object declaration to your RotateTransition compound statement at the top
of your class; then add an instantiation for this object to the end of the createAnimationAssets() method
using 5 seconds as the Duration setting and reference the camera object. Set the cycleCount variable to
one and Rate to 0.75 for a more moderate rate of movement. Set Delay to one (Duration.ONE) and use
an Interpolator.LINEAR Interpolator value for now. Finally, set the fromAngle variable to your current
-30 degrees and the toAngle variable to a target -60 degrees. This Java code can be seen at the end of your
createAnimationAssets() method, highlighted in yellow, in Figure 20-20.

Free download pdf