org.deken.game.motion
Class TwoWayMotion

java.lang.Object
  extended by org.deken.game.motion.BaseMotion
      extended by org.deken.game.motion.TwoWayMotion
All Implemented Interfaces:
Motion

public class TwoWayMotion
extends BaseMotion

Title: TwoWayMotion

Description: This animates a game piece with two directional motion. It defines a right and left animation.

Copyright: Copyright (c) 2005

Version:
1.0
Author:
Gary Deken

Field Summary
 
Fields inherited from class org.deken.game.motion.BaseMotion
boundingBox, boundingBoxSet
 
Constructor Summary
protected TwoWayMotion()
          Used by copy().
  TwoWayMotion(Animation[] animations)
          TwoWayMotion
  TwoWayMotion(Animation rightAnimation, Animation leftAnimation)
          TwoWayMotion
 
Method Summary
 TwoWayMotion copy()
          Copies the Motion.
 void draw(java.awt.Graphics2D graphics, int x, int y)
          This method gets the current animation and draws it.
 Animation[] getAnimations()
          Returns the Animations that make up this Motion
 float getDirection()
          Returns the direction of the Motion.
 java.awt.Image getImage()
          This method returns the current frame of the animation.
 java.lang.String getName()
          The method returns the name of this Motion.
 void reset()
          This resets the animation strip back to its default (or initial start) frame, based on the direction the game piece is going.
 void setDirection(float direction)
          This is for setting the direction.
 void setName(java.lang.String name)
          Sets the name for the Motion.
 void update(long elapseTime, float direction)
          This method takes the elapse time and the the direction and updates the Animation used based on the direction.
 
Methods inherited from class org.deken.game.motion.BaseMotion
getBounds, isBoundsSet, setBoundingBox, setBoundingBox
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TwoWayMotion

public TwoWayMotion(Animation rightAnimation,
                    Animation leftAnimation)
TwoWayMotion

Parameters:
rightAnimation - Animation
leftAnimation - Animation

TwoWayMotion

public TwoWayMotion(Animation[] animations)
TwoWayMotion

Parameters:
animations - Animation[]

TwoWayMotion

protected TwoWayMotion()
Used by copy().

Method Detail

copy

public TwoWayMotion copy()
Copies the Motion.

Returns:
TwoWayMotion

draw

public void draw(java.awt.Graphics2D graphics,
                 int x,
                 int y)
Description copied from interface: Motion
This method gets the current animation and draws it. The animation that is retrieved from is based on the direction the game pieces is facing. When it is used with the update method, it will draw each image in the sequence as it is updated.

Parameters:
graphics -
x -
y -

getAnimations

public Animation[] getAnimations()
Description copied from interface: Motion
Returns the Animations that make up this Motion

Returns:
Animation[]

getDirection

public float getDirection()
Description copied from interface: Motion
Returns the direction of the Motion.

Returns:
float

getImage

public java.awt.Image getImage()
Description copied from interface: Motion
This method returns the current frame of the animation. The animation that is retrieved from is based on the direction the game pieces is facing. When it is used with the update method, it will return each image in the sequence as it is updated.

Returns:
Image

getName

public java.lang.String getName()
Description copied from interface: Motion
The method returns the name of this Motion.

Returns:

reset

public void reset()
Description copied from interface: Motion
This resets the animation strip back to its default (or initial start) frame, based on the direction the game piece is going. This is useful for starting a game piece back to the beginning after it stopped or was going a different direction.


setDirection

public void setDirection(float direction)
Description copied from interface: Motion
This is for setting the direction.

Parameters:
direction - int

setName

public void setName(java.lang.String name)
Description copied from interface: Motion
Sets the name for the Motion.


update

public void update(long elapseTime,
                   float direction)
Description copied from interface: Motion
This method takes the elapse time and the the direction and updates the Animation used based on the direction.

Parameters:
elapseTime - long