Motorola E680 - Smartphone - GSM Developer's Manual page 36

Micro edition (j2me) applications
Hide thumbs Also See for E680 - Smartphone - GSM:
Table of Contents

Advertisement

Animations
As well as controlling objects from code, scene designers can specify how objects should
move under certain circumstances, and store this movement in "canned" or block
animation sequences that can be triggered from code. Many object properties are
animatable, including position, scale, orientation, color and textures. Each of these
properties can be attached to a sequence of keyframes using an AnimationTrack. The
keyframe sequence can be looped, or just played once, and they can be interpolated in
several ways (stepwise, linear, spline).
A coherent action typically requires the simultaneous animation of several properties on
several objects, the tracks are grouped together using the AnimationController object.
This allows the application to control a whole animation from one place.
All the currently active animatable properties can be updated by calling animate() on the
World. (You can also call this on individual objects if you need more control). The current
time is passed through to animate(), and is used to determine the interpolated value to
assign to the properties.
The animate() method returns a validity value that indicates how long the current value of
a property is valid. Generally this is 0 which means that the object is still being animated
and the property value is no longer valid, or infinity when the object is in a static state and
does not need to be updated. If nothing is happening in the scene, you do not have to
continually redraw the screen, reducing the processor load and extending battery life.
Similarly, simple scenes on powerful hardware may run very fast; by restricting the frame-
rate to something reasonable, you can extend battery life and are more friendly to
background processes.
The animation subsystem has no memory, so time is completely arbitrary. This means
that there are no events reported (for example, animation finished). The application is
responsible for specifying when the animation is active and from which position in the
keyframe sequence the animated property is played.
Consider a world myWorld that contains an animation of 2000 ms, that you want to cycle.
First you need to set up the active interval for the animation, and set the position of the
sequence to the start. Then call World.animate() with the current world time:
anim.setActiveInterval(worldTime, worldTime+2000);
anim.setPosition(0, worldTime);
int validity = myWorld.animate(worldTime);
36

Advertisement

Table of Contents
loading

Table of Contents