Intel Animation for Java* Package TutorialLesson 4: Animating SpritesThis applet shows an animating Elvis sprite. Click the "Adjust Current Image" button to animate Elvis once. Click the "Start Animation" to animate Elvis repeatedly. Control the animation speed with the "Faster" and "Slower" buttons. To create an animated sprite, follow the same steps from the StaticDataSprite Demo, but set the data source of the Sprite to be an ImageSequence instead of a SingleImage. An ImageSequence is a collection of SingleImages. 1. Create an ImageSequence
(repeat the following four steps for each SingleImage in the ImageSequence)
2. Create the sprite
3. Set the data source of the sprite to be the ImageSequence
Animation is done by flipping through the images in the ImageSequence (flipbook-style animation). This is done by calling
and then the new image is drawn on the screen by calling
The animation speed is controlled by the following code snippet in the run() method:
where count is initialized to 0 during applet initialization, and animDelay is adjusted to control the animation speed. This applet actually sets the transparency color to the color of the first pixel in the awt.Image. See the source code for more details.
This page was last updated on Feb 11th, 1997.
|