org.deken.game.animation
Interface Animation

All Superinterfaces:
java.lang.Cloneable, Updateable
All Known Subinterfaces:
ComplexAnimation
All Known Implementing Classes:
BaseAnimation, BounceAnimation, BounceOnceAnimation, DissolveAnimation, EllipseShapeAnimation, LayeredAnimation, LoopedAnimation, NoAnimation, OnceAnimation, RandomAnimation, RandomListAnimation, RectangleShapeAnimation, StaticAnimation, TileAnimation

public interface Animation
extends Updateable, java.lang.Cloneable

Title: Animating

Description: Interface for AnimationStrips. This interface supplies all the needed methods to connected it to either an Actor or Decor object.

Implementing this interface will allow you to create your own imaging sequence for a character.

Copyright: Copyright (c) 2005

Version:
1.0
Author:
Gary Deken

Method Summary
 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.
 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 interface org.deken.game.Updateable
getName
 

Method Detail

addFrame

void addFrame(java.awt.Image image,
              long duration)
This method is for adding an AnimationFrame to the animation strip.

Parameters:
image - Image
duration - long

addImageEffect

void addImageEffect(ImageEffect imageEffect)
This method is for adding an ImageSFX (special effect) to the animation.

Parameters:
imageEffect -

draw

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. It also performs any offsets that are needed for the image.

Parameters:
graphics -
x -
y -

reset

void reset()
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.


update

void update(long elapseTime)
This method takes the elapse time, and calculates the new current frame of the animation.

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

getFrame

java.awt.Image getFrame(int i)
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.

Parameters:
i - int
Returns:
Image

getHeight

int getHeight()
This returns the height of the animation strip.

Returns:
int

getImage

java.awt.Image getImage()
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.

Returns:
Image

getSound

Sound getSound()
Returns the sound for this animation. This is useful for getting the sound for stopping it.

Returns:
Sound

getTotalDuration

long getTotalDuration()

getWidth

int getWidth()
This returns the width of the animation strip.

Returns:
int

getXOffset

int getXOffset()
returns the Offset of the image in the X direction.

Returns:
int

getYOffset

int getYOffset()
returns the Offset of the image in the Y direction.

Returns:
int

isAnimating

boolean isAnimating()
True if this animation needs to be updated regularly. False if there is no animation to update, meaning getImage will return the same image.

Returns:
boolean

setName

void setName(java.lang.String name)
Name is used for debugging.

Parameters:
name - String

setSound

void setSound(TimeListeningSound sound)
Sound element associated with this animation. Start is the delta time that the sound should start playing at.

Parameters:
sound -

setOffsets

void setOffsets(int x,
                int y)
Sets the offset of the image, so that it displays ideally on the screen. This should default to zero.

Parameters:
x -
y -

copy

Animation copy()
Copies the animation.

Returns:
Animation