org.deken.game.sprites
Class Actor

java.lang.Object
  extended by org.deken.game.sprites.Sprite
      extended by org.deken.game.sprites.Actor
All Implemented Interfaces:
Updateable
Direct Known Subclasses:
BaseActor

public abstract class Actor
extends Sprite

Title: Actor

Description: A moving sprite.

Copyright: Copyright (c) 2005

Version:
1.0
Author:
Gary Deken

Field Summary
protected  int currentMoveMotion
           
protected  int currentStillMotion
           
protected  Movement movement
           
protected  Motion[] moveMotion
           
protected  Motion[] stillMotion
           
 
Fields inherited from class org.deken.game.sprites.Sprite
boundingBox, collisionMap, location, size
 
Constructor Summary
Actor(Motion motion, Movement movement, SpriteSize size)
           
Actor(Motion motion, Movement movement, SpriteSize size, Animation stillAnimation)
           
Actor(SpriteSize size)
          Actor This constructor is used by the DocumentManager.
 
Method Summary
protected  BaseActor copyBase(BaseActor newActor)
           
 void draw(java.awt.Graphics2D graphics, int xOffset, int yOffset)
          If the Motion has a non zero speed (it's moving), then return the AnimationMotion's image.
 BoundingBox getBounds()
           
 Motion getCurrentMoveMotion()
           
 float getDirection()
           
 Movement getMovement()
           
 Motion[] getMoveMotions()
           
 double getSpeed()
           
 Motion[] getStillMotion()
           
 void setCurrentMoveMotion(int currentMoveMotion)
           
 void setDirection(float direction)
          This is a cover method, to set the direction in the current movement Motion.
 void setMotion(Motion motion)
          This sets the first moveMotion.
 void setMovement(Movement movement)
           
 void setMoveMotions(Motion[] motions)
           
 void setStillAnimations(Animation[] stillAnimation)
           
 void setStillMotion(Motion[] stillMotion)
           
 void update(long elaspeTime)
          This method calls the update for the motion, and sets the new location, based on the updated X and Y.
protected  void updateCurrentMotion()
          This sets the current motion indices based on the current speed of the Actor.
protected  void updateLocationX()
           
protected  void updateLocationY()
           
 
Methods inherited from class org.deken.game.sprites.Sprite
copy, getDepth, getHeight, getLocation, getName, getSize, getWidth, getXLocation, getYLocation, removeFromMap, setBoundingBox, setBoundingBox, setCollisionMap, setLocation, setName, setSize, spriteCollison, toString, updateLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

movement

protected Movement movement

moveMotion

protected Motion[] moveMotion

currentMoveMotion

protected int currentMoveMotion

stillMotion

protected Motion[] stillMotion

currentStillMotion

protected int currentStillMotion
Constructor Detail

Actor

public Actor(SpriteSize size)
Actor This constructor is used by the DocumentManager. It is not recommended to use this outside of that class.

Parameters:
size - PieceSize

Actor

public Actor(Motion motion,
             Movement movement,
             SpriteSize size)
Parameters:
motion - Motion
movement - Movement
size - SpriteSize

Actor

public Actor(Motion motion,
             Movement movement,
             SpriteSize size,
             Animation stillAnimation)
Parameters:
motion - Motion
movement - Movement
size - SpriteSize
stillAnimation - Animation
Method Detail

draw

public void draw(java.awt.Graphics2D graphics,
                 int xOffset,
                 int yOffset)
If the Motion has a non zero speed (it's moving), then return the AnimationMotion's image. If there is no speed, return the still Animation.

Specified by:
draw in class Sprite
Parameters:
graphics -
xOffset -
yOffset -

getBounds

public BoundingBox getBounds()
Overrides:
getBounds in class Sprite
Returns:
Rectangle2D

getDirection

public float getDirection()
Returns:
float

getCurrentMoveMotion

public Motion getCurrentMoveMotion()
Returns:
Motion

getMoveMotions

public Motion[] getMoveMotions()

getMovement

public Movement getMovement()
Returns:
Movement

getSpeed

public double getSpeed()
Returns:
double

getStillMotion

public Motion[] getStillMotion()

setCurrentMoveMotion

public void setCurrentMoveMotion(int currentMoveMotion)

setDirection

public void setDirection(float direction)
This is a cover method, to set the direction in the current movement Motion.

Parameters:
direction - float

setMotion

public void setMotion(Motion motion)
This sets the first moveMotion. The currentMoveMotion is set to zero.

Parameters:
motion - Motion

setMoveMotions

public void setMoveMotions(Motion[] motions)
Parameters:
motions -

setMovement

public void setMovement(Movement movement)
Parameters:
movement - Movement

setStillAnimations

public void setStillAnimations(Animation[] stillAnimation)
Parameters:
stillAnimation -

setStillMotion

public void setStillMotion(Motion[] stillMotion)

update

public void update(long elaspeTime)
This method calls the update for the motion, and sets the new location, based on the updated X and Y.

Specified by:
update in interface Updateable
Specified by:
update in class Sprite
Parameters:
elaspeTime - long

copyBase

protected BaseActor copyBase(BaseActor newActor)
Parameters:
newActor -
Returns:
Copy of this Actor object.

updateCurrentMotion

protected void updateCurrentMotion()
This sets the current motion indices based on the current speed of the Actor. The default sets the current motion indices to zero. Override this method for customizations.


updateLocationX

protected void updateLocationX()

updateLocationY

protected void updateLocationY()