Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

© Wallace Jackson 2017 389
W. Jackson, Pro Java 9 Games Development, https://doi.org/10.1007/978-1-4842-0973-8_16


CHAPTER 16


3D Game Animation Creation:


Using the Animation Transition


Classes


Now that you have created the multitiered gameBoard Group Node (subclass) hierarchy, textured all of
the 3D components underneath that hierarchy, made sure that your 3D game board model center-rotates,
and created a 3D spinner UI to randomly rotate this gameBoard 3D model (hierarchy) to select a random
quadrant, it’s time to add animation objects to the game design using a custom createAnimationAssets()
method for the spinner to call to create random “spins” for use during gameplay. We’ll also set up 3D
object mouse click event handling code to trigger the animation and the logic that will randomize your
RotateTransition parameters before this spin is undertaken.
During the chapter, we take a detailed look at the abstract Animation and Transition superclasses and
all of the powerful property transition subclasses, which you can implement as different types of Animation
objects in your i3D board game. We’ll animate rotation for your game board and spinner, as well as the
translation (movement) for the spinner.


Animating the 3D Assets: The Animation Superclass


The public abstract Animation class extends Object and is kept in the javafx.animation package, as are the
other animation-related classes, some of which we will be using for our game and will be covering in detail
during this chapter. The Animation superclass has two direct known subclasses, Timeline and Transition.
Transition has ten predefined Animation (algorithm) subclasses, ready to apply to your game development,
so we will focus on them since they can be used immediately and effectively. The javafx.animation
package could have an entire book written on it, and I have only one chapter, so I’ll cover the most effective
animation classes to use to create pro Java 9 games with.
The Java 9 class hierarchy for the Animation superclass shows us that the class was scratch-coded to
provide object animation capabilities as it has no superclass of its own and therefore looks like the following
class hierarchy:


java.lang.Object



javafx.animation.Animation


Free download pdf