Tino APCS

Basic Animation - Transition Classes

Java FX provides a large assortment of animation tools in the Animation package. We will go over how to use the Transition classes.

Methods common to all types of Animation are:

Method Description
setAutoReverse(boolean) - false: animations will repeat from beginning to end
- true: animations will play in reverse before repeating
setCycleCount(int) - Animations will play from beginning to end this many times.
- If AutoReverse is true, odd cycles are forward, even are backward.
- For infinite looping, use an argument of Animation.INDEFINITE
setDelay(Duration) Delays the start of an animation after play() is called
setRate(double) - Changes the playback rate as compared to a normal rate of 1.0
- For example, (0.5) is half speed, (2.0) is double speed, (-1.0) is reverse normal speed, (-2.0) is reverse double speed, etc.
play() Starts an animation
setOnFinished(EventHandler<ActionEvent>) Attaches an event handler to the Animation so that it runs a custom handle() method when the Animation finishes.

Dark Mode

Outline