Java Reference
In-Depth Information
The next few sections cover these animation classes and demonstrate their use.
After that, we will revisit our Eclipse animation example based on the graphical
objects we created with the JavaFX Production Suite in Chapter 2, JavaFX for
the Graphic Designer.
Timelines
A timeline provides the ability to update animation associated properties over a
period of time. A timeline is defined by one or more sequential key frames
ordered by their respective time within the timeline. The animation properties are
then changed over the time period using a mathematical formula to a new target
value.
A timeline may move either forward or backward in time. Also, it may play its
cycle one or more times, or even indefinitely. You can specify that it alternates
direction for each cycle so that it plays forward then backwards. You can also
speed up or slow down the rate of play. Timelines can also be paused, resumed,
or stopped. In addition, you can set when to start or restart, either at the begin-
ning or at some intermediate point within the timeline.
A sample Timeline object literal is shown in Listing 7.1 with the key points
highlighted. The KeyFrame syntax will be covered in the next section.
Listing 7.1
Timeline Object Literal
import javafx.animation.*;
// point on screen
var x: Integer;
var y: Integer;
var timeline = Timeline {
// go forward, then backward on alternating cycle
autoReverse : true
repeatCount : Timeline.INDEFINITE // run until stopped
// normal time, 2x would be 2.0, half speed is 0.5
rate : 1.0
keyFrames : [
// at 0 milli seconds, set x/y to initial value
at(0ms) {
x => 0;
y => 0;
},
continues
 
Search WWH ::




Custom Search