com.brackeen.javagamebook.graphics
Class Animation

java.lang.Object
  extended by com.brackeen.javagamebook.graphics.Animation

public class Animation
extends java.lang.Object

The Animation class manages a series of images (frames) and the amount of time to display each frame.


Nested Class Summary
private  class Animation.AnimFrame
           
 
Field Summary
private  long animTime
           
private  int currFrameIndex
           
private  java.util.ArrayList frames
           
private  long totalDuration
           
 
Constructor Summary
  Animation()
          Creates a new, empty Animation.
private Animation(java.util.ArrayList frames, long totalDuration)
           
 
Method Summary
 void addFrame(java.awt.Image image, long duration)
          Adds an image to the animation with the specified duration (time to display the image).
 java.lang.Object clone()
          Creates a duplicate of this animation.
private  Animation.AnimFrame getFrame(int i)
           
 java.awt.Image getImage()
          Gets this Animation's current image.
 void start()
          Starts this animation over from the beginning.
 void update(long elapsedTime)
          Updates this animation's current image (frame), if neccesary.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

frames

private java.util.ArrayList frames

currFrameIndex

private int currFrameIndex

animTime

private long animTime

totalDuration

private long totalDuration
Constructor Detail

Animation

public Animation()
Creates a new, empty Animation.


Animation

private Animation(java.util.ArrayList frames,
                  long totalDuration)
Method Detail

clone

public java.lang.Object clone()
Creates a duplicate of this animation. The list of frames are shared between the two Animations, but each Animation can be animated independently.

Overrides:
clone in class java.lang.Object

addFrame

public void addFrame(java.awt.Image image,
                     long duration)
Adds an image to the animation with the specified duration (time to display the image).


start

public void start()
Starts this animation over from the beginning.


update

public void update(long elapsedTime)
Updates this animation's current image (frame), if neccesary.


getImage

public java.awt.Image getImage()
Gets this Animation's current image. Returns null if this animation has no images.


getFrame

private Animation.AnimFrame getFrame(int i)