Class Animation

Class Animation

Animation

class Animation
extends Panel
Class representing an animation. Each animation is a series of frames of consistent and constant size that get displayed for a fixed amount of time. There are two types of animations, one-shot and looping. One-shot animations run once, looping animations run continually until they are stopped from outside.

Variable Index

 o FrameNumber
This index indicates which frame of the animation will be displayed next.
 o bOneShot
If this animation runs only one, this gets set to true.
 o bRunning
Is this animation actually animating now?
 o images
The images comprising the stages of the animation.

Constructor Index

 o Animation(Applet)
Constructor - store the applet to call back to
 o Animation(Applet, AgentImage[], AgentFace)
Create an animation that is not animating right now.

Method Index

 o minimumSize()
This method tells the LayoutManager the smallest size we can be.
 o mouseDown(Event, int, int)
Called if the user clicks the mouse in this Panel.
 o nextImage()
Go to the next image.
 o paint(Graphics)
Paint a single frame of this animation within an existing Graphics context.
 o preferredSize()
This method tells the LayoutManager the size we prefer to be.
 o updateNextImage()
Go to the next image and display it.

Variables

 o bRunning
  public boolean bRunning
Is this animation actually animating now?
 o images
  public AgentImage images[]
The images comprising the stages of the animation.
 o bOneShot
  public boolean bOneShot
If this animation runs only one, this gets set to true. If this is a loop that restarts at the beginning, set this to false.
 o FrameNumber
  public int FrameNumber
This index indicates which frame of the animation will be displayed next.

Constructors

 o Animation
  public Animation(Applet al)
Constructor - store the applet to call back to
Parameters:
al - An applet to call back to.
 o Animation
  public Animation(Applet al,
                   AgentImage im[],
                   AgentFace agf)
Create an animation that is not animating right now.

Methods

 o minimumSize
  public synchronized Dimension minimumSize()
This method tells the LayoutManager the smallest size we can be. In our case, it's the size of the image we're displaying.
Returns:
A Dimension - width and height.
 o preferredSize
  public synchronized Dimension preferredSize()
This method tells the LayoutManager the size we prefer to be. In our case, it's the size of the image we're displaying.
Returns:
A Dimension - width and height.
 o paint
  public void paint(Graphics g)
Paint a single frame of this animation within an existing Graphics context.
 o nextImage
  public void nextImage()
Go to the next image. Increments FrameNumber, rewinding back to 0 if we've gone over the edge of the array.
 o updateNextImage
  public void updateNextImage()
Go to the next image and display it.
 o mouseDown
  public boolean mouseDown(Event e,
                           int x,
                           int y)
Called if the user clicks the mouse in this Panel.
Returns:
false