Pro Java 9 Games Development Leveraging the JavaFX APIs

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

Now we can add the .setOnFinished() event handling construct to the cameraAnimOut Animation
object to automatically turn on your spinnerClick function once the camera has animated back out to game
board spin view so that the player can click the i3D spinner UI element to start the gameplay process all over
again. The Java code for this functionality is shown here using a single line of code and is highlighted in light
blue and yellow in Figure 23-29:


cameraAnimOut = new ParallelTransition(moveCameraOut, rotCameraBack, moveSpinnerOn);
cameraAnimOut.setOnFinished( event-> { spinnerClick = true; } );


Figure 23-28. Call resetTextureMaps(), cameraAnimOut.play(), and cameraAudio.play() in
againButton.setOnAction()


Figure 23-29. Add a cameraAnimOut.setOnFinsihed() event handler that sets the spinnerClick variable to a
true value

Free download pdf