Pro Java 9 Games Development Leveraging the JavaFX APIs

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

We’ll move the spinner off quickly, in 2 seconds, by the same 150 units (this time negative) that we
moved the spinner onto the screen by. The Java code should look like the following, as shown in Figure 20-22
at the bottom of the method, highlighted in yellow and light blue:


moveCameraIn = new TranslateTransition(Duration.seconds(2), camera);
moveCameraIn.setByZ(-175);
moveCameraIn.setCycleCount(1);
moveSpinnerOff = new TranslateTransition(Duration.seconds( 3 ), spinner);
moveSpinnerOff.setByX(-150);
moveSpinnerOff.setCycleCount( 1 );
cameraAnimIn = new ParallelTransition(moveCameraIn, rotCameraDown, moveSpinnerOff);


These four new Animation objects will add quite a bit of professionalism to your i3D game, animating
your camera view into a vastly superior position, removing the spinner i3D UI element from the screen
for each core gameplay session, rotating the 3D camera’s plane so that it is more parallel to your quadrant
content, and combining all of this movement into one ParallelTransition animation sequence.
This sets things up for the next chapter, where we’ll be adding digital audio sound effects both to the
game board spin and to the camera zoom by using a ParallelTransition object. This will make both these 3D
animation objects even more fun to use for our i3D board game players.


Figure 20-22. Add a moveSpinnerOff Animation object to a cameraAnimIn ParallelTransition object to
remove the spinner

Free download pdf