Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 16 ■ 3D Game animation Creation: UsinG the animation transition Classes

Next, let’s take a look at the ParallelTransition class since we’ll need to use this object algorithm to
combine the spinner rotSpinner Animation object with a moveSpinnerOn Animation object so that your
final result is a spinner that spins while it is moving across the top of the screen.


Merging Animation Properties: Using a ParallelTransition Class


The public final class ParallelTransition extends the abstract Transition superclass and can be found in
the javafx.animation package, which can be found in the javafx.graphics module. This Transition plays
a list of Animation objects in parallel, which means at the same time (one after the other is termed serial
or sequential). Children of this Transition inherit the Node node property if their node property has not
been explicitly specified using a method call (usually the constructor method). The reason for this is that a
ParallelTransition simply merges existing Animation objects together, so a node may already be specified in
the merged animations. The Java class hierarchy for the ParallelTransition looks like this:


java.lang.Object



javafx.animation.Animation
javafx.animation.Transition
javafx.animation.ParallelTransition



Figure 16-9. Declare a moveSpinnerOn TranslateTransition at the top of the class and instantiate it in
createAnimationAssets()

Free download pdf