Java Reference
In-Depth Information
def animation = PathTransition {
node: racear
path: AnimationPath.createFromPath(route)
orientation: OrientationType.ORTHOGONAL_TO_TANGENT
interpolate: Interpolator.LINEAR
duration: duration
repeatCount: Timeline.INDEFINITE
};
Notice the orientation instance variable. By setting this to ORTHOGONAL_TO_
TANGENT , the race car image rotates to match the path while traversing the route.
The other option is to set this to NONE , the default. When orientation is set to
NONE , the race car will not rotate at all. Obviously, for an object like a race car
that has inherent direction, this is probably not desirable. However, if you have a
node that does not imply direction, like a Circle , then setting it to NONE would
be sufficient.
The last step is to create the presentation showing the map of midtown Manhattan,
and adding the race car image and the route.
Group {
translateX: bind (scene.width - image.width)/2
content: [
ImageView{
image: image
},
route, racear
]
},
Using the animation variable, you can control the play of the animation similar
to regular types of timelines. Figure 7.8 shows the map of midtown Manhattan,
New York City, with a car image on the street. In this animation, the car travels
along a route on the map.
Listing 7.5 shows the main code for traversing the map. The full example, Path-
Animation , can be downloaded from http://jfxbook.com.
Search WWH ::




Custom Search