org.deken.game.animation
Class RandomListAnimation

java.lang.Object
  extended by org.deken.game.animation.RandomListAnimation
All Implemented Interfaces:
java.lang.Cloneable, Animation, ComplexAnimation, Updateable

public class RandomListAnimation
extends java.lang.Object
implements ComplexAnimation

Title: RandomListAnimation

Description: A decorator for the Animation interface, that create a random Animation from a list a Animations.

Copyright: Copyright (c) May 20, 2012

Version:
1.0
Author:
Gary Deken

Constructor Summary
protected RandomListAnimation()
           
  RandomListAnimation(java.util.List<Animation> animations)
           
 
Method Summary
 void addAnimation(int index, Animation animation)
          The index is not used in the RandomListAnimation
 void addFrame(java.awt.Image image, long duration)
          This method is for adding an AnimationFrame to the animation strip.
 void addImageEffect(ImageEffect imageEffect)
          This method is for adding an ImageSFX (special effect) to the animation.
 Animation copy()
          Copies the animation.
 void draw(java.awt.Graphics2D graphics, int x, int y)
          Draws the current frame or shape of the animation at the set x and y location.
 java.awt.Image getFrame(int i)
          This method returns an Image at a given frame location.
 int getHeight()
          This returns the height of the animation strip.
 java.awt.Image getImage()
          This method returns the current frame of the animation.
 java.lang.String getName()
           
 Sound getSound()
          Returns the sound for this animation.
 long getTotalDuration()
           
 int getWidth()
          This returns the width of the animation strip.
 int getXOffset()
          returns the Offset of the image in the X direction.
 int getYOffset()
          returns the Offset of the image in the Y direction.
 boolean isAnimating()
          True if this animation needs to be updated regularly.
 void reset()
          This resets the animation strip back to its default (or initial start) frame.
 void setName(java.lang.String name)
          Name is used for debugging.
 void setOffsets(int x, int y)
          Sets the offset of the image, so that it displays ideally on the screen.
 void setSound(TimeListeningSound sound)
          Sound element associated with this animation.
 void update(long elapseTime)
          This method takes the elapse time, and calculates the new current frame of the animation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomListAnimation

public RandomListAnimation(java.util.List<Animation> animations)

RandomListAnimation

protected RandomListAnimation()
Method Detail

addAnimation

public void addAnimation(int index,
                         Animation animation)
The index is not used in the RandomListAnimation

Specified by:
addAnimation in interface ComplexAnimation
Parameters:
index -
animation -

addFrame

public void addFrame(java.awt.Image image,
                     long duration)
Description copied from interface: Animation
This method is for adding an AnimationFrame to the animation strip.

Specified by:
addFrame in interface Animation
Parameters:
image - Image
duration - long

addImageEffect

public void addImageEffect(ImageEffect imageEffect)
Description copied from interface: Animation
This method is for adding an ImageSFX (special effect) to the animation.

Specified by:
addImageEffect in interface Animation

copy

public Animation copy()
Description copied from interface: Animation
Copies the animation.

Specified by:
copy in interface Animation
Returns:
Animation

draw

public void draw(java.awt.Graphics2D graphics,
                 int x,
                 int y)
Description copied from interface: Animation
Draws the current frame or shape of the animation at the set x and y location. It also performs any offsets that are needed for the image.

Specified by:
draw in interface Animation

getFrame

public java.awt.Image getFrame(int i)
Description copied from interface: Animation
This method returns an Image at a given frame location. NOTE: this is useful for getting a static (stand still) image for a game piece.

Specified by:
getFrame in interface Animation
Parameters:
i - int
Returns:
Image

getHeight

public int getHeight()
Description copied from interface: Animation
This returns the height of the animation strip.

Specified by:
getHeight in interface Animation
Returns:
int

getName

public java.lang.String getName()
Specified by:
getName in interface Updateable
Returns:

getImage

public java.awt.Image getImage()
Description copied from interface: Animation
This method returns the current frame of the animation. When it is used with the update method, it will return each image in the sequence as it is updated.

Specified by:
getImage in interface Animation
Returns:
Image

getSound

public Sound getSound()
Description copied from interface: Animation
Returns the sound for this animation. This is useful for getting the sound for stopping it.

Specified by:
getSound in interface Animation
Returns:
Sound

getTotalDuration

public long getTotalDuration()
Specified by:
getTotalDuration in interface Animation

getWidth

public int getWidth()
Description copied from interface: Animation
This returns the width of the animation strip.

Specified by:
getWidth in interface Animation
Returns:
int

getXOffset

public int getXOffset()
Description copied from interface: Animation
returns the Offset of the image in the X direction.

Specified by:
getXOffset in interface Animation
Returns:
int

getYOffset

public int getYOffset()
Description copied from interface: Animation
returns the Offset of the image in the Y direction.

Specified by:
getYOffset in interface Animation
Returns:
int

isAnimating

public boolean isAnimating()
Description copied from interface: Animation
True if this animation needs to be updated regularly. False if there is no animation to update, meaning getImage will return the same image.

Specified by:
isAnimating in interface Animation
Returns:
boolean

reset

public void reset()
Description copied from interface: Animation
This resets the animation strip back to its default (or initial start) frame. This is useful for starting a game piece back to the begining after it stops.

Specified by:
reset in interface Animation

setName

public void setName(java.lang.String name)
Description copied from interface: Animation
Name is used for debugging.

Specified by:
setName in interface Animation
Parameters:
name - String

setSound

public void setSound(TimeListeningSound sound)
Description copied from interface: Animation
Sound element associated with this animation. Start is the delta time that the sound should start playing at.

Specified by:
setSound in interface Animation

setOffsets

public void setOffsets(int x,
                       int y)
Description copied from interface: Animation
Sets the offset of the image, so that it displays ideally on the screen. This should default to zero.

Specified by:
setOffsets in interface Animation

update

public void update(long elapseTime)
Description copied from interface: Animation
This method takes the elapse time, and calculates the new current frame of the animation.

Specified by:
update in interface Animation
Specified by:
update in interface Updateable
Parameters:
elapseTime - long