Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 23 ■ Completing the gameplay Code and player proofing your event handling

So, now we can create your ParallelTransition cameraAnimOut object, which will play the
moveCameraOut, rotCameraBack, and moveSpinnerOn Animation objects in parallel or at exactly the
same time! This will require only a single line of code instantiating the cameraAnimOut object and using its
constructor method to load that object with the other three Animation object references. We’ll eventually
add a second line of code calling a .setOnFinished() method off of this object so that we can reset the
spinnerClick boolean variable to false once the camera has zoomed back out so that your player is able to
use the i3D spinner UI element again to randomly spin the game board again.
The Java code for doing this should look like the following and is shown highlighted in light blue and
yellow at the bottom of Figure 23-27:


cameraAnimOut = new ParallelTransition(moveCameraOut, rotCameraBack, moveSpinnerOn);


Now we can go back to finishing the code for the againButton.setOnAction() construct, refining that result.

Figure 23-27. Create cameraAnimOut ParallelTransition and reference moveCameraOut, rotCameraback,
and moveSpinnerOn

Free download pdf