org.deken.game.animation
Class TileAnimation

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

public class TileAnimation
extends BaseAnimation

Title: TileAnimationStrip Description: Copyright: Copyright (c) 2005

Version:
1.0
Author:
Gary Deken

Field Summary
 
Fields inherited from class org.deken.game.animation.BaseAnimation
height, imageEffect, name, sequenceTime, sound, totalDuration, totalFrames, width, xOffset, yOffset
 
Constructor Summary
protected TileAnimation()
          Used by copy().
 
Method Summary
 void addFrame(java.awt.Image image, long duration)
          Animation Strip
 TileAnimation copy()
          Copy Animation
 void draw(java.awt.Graphics2D graphics, int x, int y)
          Draws the current frame index to the GameGFX, including any animation offsets.
 boolean equals(java.lang.Object obj)
          Determines if two animation strips are the same, based on size of image and number of frames.
 float getDirection()
          Returns the direction the tile is moving.
 java.awt.Image getFrame(int i)
          This method returns an Image at a given frame location.
 java.awt.Image getImage()
          This method returns the current frame of the animation.
 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 setDirection(float direction, double speed)
          Set the direction and speed the tile moves.
 void update(long elapseTime)
          This method takes the elapse time, and calculates the new current frame of the animation.
 
Methods inherited from class org.deken.game.animation.BaseAnimation
addImageEffect, baseUpdate, copyParent, getHeight, getName, getSound, getTotalDuration, getWidth, getXOffset, getYOffset, setName, setOffsets, setSound
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TileAnimation

protected TileAnimation()
Used by copy().

Method Detail

addFrame

public void addFrame(java.awt.Image image,
                     long duration)
Animation Strip

Parameters:
image -
duration -

draw

public void draw(java.awt.Graphics2D graphics,
                 int x,
                 int y)
Draws the current frame index to the GameGFX, including any animation offsets.

Parameters:
graphics -
x -
y -

equals

public boolean equals(java.lang.Object obj)
Determines if two animation strips are the same, based on size of image and number of frames.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Object
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.


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.

Parameters:
elapseTime - long

getDirection

public float getDirection()
Returns the direction the tile is moving.

Returns:
float

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.

Parameters:
i - int
Returns:
Image

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.

Returns:
Image

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.

Returns:
boolean

setDirection

public void setDirection(float direction,
                         double speed)
Set the direction and speed the tile moves.

Parameters:
direction - float
speed - double

copy

public TileAnimation copy()
Copy Animation

Returns:
TileAnimationStrip