Java Reference
In-Depth Information
Using a Timeline for Animation
Take a look at the
javafx.animation
package in the JavaFX API docs, and you see three of the classes that are used
when directly creating a timeline:
Timeline
,
KeyFrame
, and
Interpolator
. Peruse the docs for these classes, and then
come back so we can show you some examples of using them.
■
remember to consult the JavafX api docs for any new packages, classes, properties, and methods that
you encounter.
Tip
The Metronome1 Example
We use a simple metronome example to demonstrate how to create a timeline.
As the screenshot in Figure
2-8
shows, the Metronome1 program has a pendulum as well as four buttons that
start, pause, resume, and stop the animation. The pendulum in this example is a
Line
node, and we're going to
animate that node by
interpolating
its
startX
property over the period of one second. Go ahead and take this example
for a spin by doing the following exercise.
Figure 2-8.
The Metronome1 program
Search WWH ::
Custom Search