com.golden.gamedev.object
Class Sprite

java.lang.Object
  |
  +--com.golden.gamedev.object.Sprite
Direct Known Subclasses:
AnimatedSprite, AnimationSprite, PatternSprite, PlatformSprite

public class Sprite
extends Object

Sprite is a graphical object that have its own behaviour. Sprite behaviour is usually managed by Timer class.


Field Summary
protected  int height
           
 int speedX
           
 int speedY
           
protected  int width
           
 
Constructor Summary
Sprite()
          Creates new empty Sprite.
Sprite(BufferedImage image, int x, int y)
          Creates new Sprite with specified image and position.
Sprite(int x, int y)
          Creates new Sprite with specified position.
 
Method Summary
 void forceX(int xs)
           
 void forceY(int ys)
           
 Background getBackground()
           
 int getHeight()
           
 int getID()
           
 BufferedImage getImage()
           
 int getLayer()
          Layer can be used for z-order rendering.
 Timer getMovementTimer()
           
 int getOldX()
           
 int getOldY()
           
 int getScreenX()
           
 int getScreenY()
           
 int getSpeedX()
           
 int getSpeedY()
           
 int getWidth()
           
 int getX()
           
 int getY()
           
 boolean isActive()
           
 boolean isOnScreen()
           
 boolean isOnScreen(int leftOffset, int topOffset, int rightOffset, int bottomOffset)
           
 void move(int dx, int dy)
           
 void moveX(int dx)
           
 void moveY(int dy)
           
 void render(Graphics2D g)
           
 void render(Graphics2D g, int x, int y)
           
 void setActive(boolean b)
           
 void setBackground(Background backgr)
           
 void setID(int id)
           
 void setImage(BufferedImage image)
           
 void setLayer(int i)
           
 void setLocation(int xs, int ys)
           
 void setMovementTimer(Timer t)
           
 void setSpeed(int sx, int sy)
           
 void setSpeedX(int i)
           
 void setSpeedY(int i)
           
 void setX(int xs)
           
 void setY(int ys)
           
 void update()
           
protected  void updateMovement()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

speedX

public int speedX

speedY

public int speedY

width

protected int width

height

protected int height
Constructor Detail

Sprite

public Sprite(BufferedImage image,
              int x,
              int y)
Creates new Sprite with specified image and position.


Sprite

public Sprite(int x,
              int y)
Creates new Sprite with specified position.


Sprite

public Sprite()
Creates new empty Sprite.

Method Detail

setBackground

public void setBackground(Background backgr)

getBackground

public Background getBackground()

getImage

public BufferedImage getImage()

setImage

public void setImage(BufferedImage image)

getWidth

public int getWidth()

getHeight

public int getHeight()

setLocation

public void setLocation(int xs,
                        int ys)

move

public void move(int dx,
                 int dy)

setX

public void setX(int xs)

setY

public void setY(int ys)

forceX

public void forceX(int xs)

forceY

public void forceY(int ys)

getX

public int getX()

getY

public int getY()

getOldX

public int getOldX()

getOldY

public int getOldY()

moveX

public void moveX(int dx)

moveY

public void moveY(int dy)

setSpeed

public void setSpeed(int sx,
                     int sy)

setSpeedX

public void setSpeedX(int i)

setSpeedY

public void setSpeedY(int i)

getSpeedX

public int getSpeedX()

getSpeedY

public int getSpeedY()

getScreenX

public int getScreenX()

getScreenY

public int getScreenY()

isOnScreen

public boolean isOnScreen(int leftOffset,
                          int topOffset,
                          int rightOffset,
                          int bottomOffset)

isOnScreen

public boolean isOnScreen()

render

public void render(Graphics2D g)

render

public void render(Graphics2D g,
                   int x,
                   int y)

update

public void update()

updateMovement

protected void updateMovement()

getID

public int getID()

setID

public void setID(int id)

getLayer

public int getLayer()
Layer can be used for z-order rendering. Use this in PlayField.setComparator(Comparator) or SpriteGroup.setComparator(Comparator) for that purpose.


setLayer

public void setLayer(int i)

isActive

public boolean isActive()

setActive

public void setActive(boolean b)

setMovementTimer

public void setMovementTimer(Timer t)

getMovementTimer

public Timer getMovementTimer()