danger.ui
Class Sprite

java.lang.Object
  extended by danger.ui.Sprite
Direct Known Subclasses:
BitmapSprite


public abstract class Sprite
extends Object

A Sprite manages a moving visible object. You can use it for certain forms of animation. It keeps track of the location of the sprite.


Constructor Summary
Sprite()
          Construct an instance of Sprite.
 
Method Summary
 void advance()
          Advance the sprite to the next position, dependent on the the velocity set in setVelocity(danger.ui.Point).
 Point getPosition()
          Get the current position of the sprite.
 Point getPosition(Point inPoint)
          Get the current position of the sprite.
abstract  void paint(Pen inPen)
          Paint the sprite at the current location.
 void setHotSpot(int inHotX, int inHotY)
          Set the hot spot for the sprite.
 void setHotSpot(Point inHotSpot)
          Set the hot spot for the sprite.
 void setPosition(int inX, int inY)
          Set the position of the sprite.
 void setPosition(Point inPosition)
          Set the position of the sprite.
 void setVelocity(int inVelocityH, int inVelocityV)
          Set the sprite's velocity.
 void setVelocity(Point inVelocity)
          Set the sprite's velocity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sprite

public Sprite()
Construct an instance of Sprite. By default, it is stationary.

Method Detail

setHotSpot

public void setHotSpot(Point inHotSpot)
Set the hot spot for the sprite. This sprite will be drawn such that the hot spot is placed at the position set by setPosition(danger.ui.Point) and subsequently changed depending on the sprite's velocity.


setHotSpot

public void setHotSpot(int inHotX,
                       int inHotY)
Set the hot spot for the sprite. This sprite will be drawn such that the hot spot is placed at the position set by setPosition(danger.ui.Point) and subsequently changed depending on the sprite's velocity.


setVelocity

public void setVelocity(Point inVelocity)
Set the sprite's velocity. This specifies the sprite's direction and how much it moves each time advance() is called.


setVelocity

public void setVelocity(int inVelocityH,
                        int inVelocityV)
Set the sprite's velocity. This specifies the sprite's direction and how much it moves each time advance() is called.


advance

public void advance()
Advance the sprite to the next position, dependent on the the velocity set in setVelocity(danger.ui.Point).


setPosition

public void setPosition(Point inPosition)
Set the position of the sprite.


setPosition

public void setPosition(int inX,
                        int inY)
Set the position of the sprite.


getPosition

public Point getPosition()
Get the current position of the sprite.


getPosition

public Point getPosition(Point inPoint)
Get the current position of the sprite.

Returns:
Always returns the point that was passed into it.

paint

public abstract void paint(Pen inPen)
Paint the sprite at the current location.