com.wistrand.midlet.sprite
Class Sprite

java.lang.Object
  |
  +--com.wistrand.midlet.sprite.Sprite
Direct Known Subclasses:
BalloonSprite, HeartSprite, MultiSprite, PolySprite

public abstract class Sprite
extends java.lang.Object

Base class for simple movable objects, sprites.


Field Summary
 int col
           
 int dx
           
 int dy
           
 int id
           
protected static int idCount
           
 Sprite parent
           
 int px
           
 int py
           
 int rot
           
 int size
           
 int x
           
 int y
           
 
Constructor Summary
Sprite()
           
 
Method Summary
 void moveTo(int x, int y)
          Move to a new coordinate.
abstract  void paint(javax.microedition.lcdui.Graphics g)
          Paint the sprite on a Graphics.
 void setColor(int col)
           
 void setParent(Sprite parent, int px, int py)
          Set the sprite parent.
 void setSpeed(int dx, int dy)
          Set sprite speed.
 java.lang.String toString()
           
 void update()
          Update position by adding speed to current pos.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public int x

y

public int y

dx

public int dx

dy

public int dy

size

public int size

rot

public int rot

col

public int col

id

public int id

parent

public Sprite parent

px

public int px

py

public int py

idCount

protected static int idCount
Constructor Detail

Sprite

public Sprite()
Method Detail

setParent

public void setParent(Sprite parent,
                      int px,
                      int py)
Set the sprite parent. Position will be relative to this parent.
Parameters:
parent - Sprite to be relative to. If null, don't use a parent.
px - X relative coordinate to parent.
py - Y relative coordinate to parent.

setColor

public void setColor(int col)

moveTo

public void moveTo(int x,
                   int y)
Move to a new coordinate.

setSpeed

public void setSpeed(int dx,
                     int dy)
Set sprite speed.

update

public void update()
Update position by adding speed to current pos.

paint

public abstract void paint(javax.microedition.lcdui.Graphics g)
Paint the sprite on a Graphics. Should be overridden by subclasses since the default method does nothing.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object