Pro Java 9 Games Development Leveraging the JavaFX APIs

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

We do want to turn the spinner mouse click on, however, after the spinner has come in again to the
screen, which is the rotSpinnerIn Animation object. For this reason, we’ll set your spinnerClick to true in
the .setOnFinished() event handling logic. Again, the Java programming is logical here, and there’s nothing
surprising if you just think about what you want to achieve in your gameplay pipeline. It’s a lot to think about
all at once, as most gameplay logic is, so it may be difficult to do at first, until you get used to thinking about
all your real-time gameplay logic at once as it relates to the logic (processing pipeline) involved in processing
your real-time, interactive gameplay. This is why game development is considered difficult by most, as you
need to “wrap your head around” all of your gameplay code at once as a coder.
The new Java code in the createSceneProcessing() method is shown here, as well as highlighted in
light blue and yellow in Figure 23-13 in the blocks of code that set up the logic used for your rotSpinner and
rotSpinnerIn:


rotSpinner = new RotateTransition(Duration.seconds(5), spinner);
...
rotSpinner.setOnFinished(event-> {
spinnerClick = false;
});
rotSpinnerIn = new RotateTransition(Duration.seconds(5), spinner);
...
rotSpinnerIn.setOnFinished(event-> {
spinnerClick = true;
});


Figure 23-13. Set spinnerClick to false in rotSpinner and to true in rotSpinnerIn to control when the spinner is
to be clicked

Free download pdf