|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectse.liu.student.kimgr905.tilegame.sprites.Sprite
public class Sprite
A sprite is a object with a Animation, and information about x and y-position as well as velocity and current state.
| Field Summary | |
|---|---|
(package private) Animation |
anim
|
private float |
dx
|
private float |
dy
|
private int |
state
|
static int |
STATE_DEAD
The Sprite is dead. |
static int |
STATE_EXPLODING
The Sprite is exploding. |
static int |
STATE_NORMAL
The Sprite is normal. |
static int |
STATE_SHOOTING
The Sprite is shooting. |
private float |
x
|
private float |
y
|
| Constructor Summary | |
|---|---|
Sprite(Animation anim)
Creates a new Sprite object with the specified Animation. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Clone is used to make a deepcopy of this Sprite. |
int |
getHeight()
Gets this Sprite's height, based on the size of the current image. |
java.awt.Image |
getImage()
Gets this Sprite's current image. |
int |
getState()
Gets the state of this Creature. |
float |
getVelocityX()
Gets the horizontal velocity of this Sprite in pixels per millisecond. |
float |
getVelocityY()
Gets the vertical velocity of this Sprite in pixels per millisecond. |
int |
getWidth()
Gets this Sprite's width, based on the size of the current image. |
float |
getX()
Gets this Sprite's current x position. |
float |
getY()
Gets this Sprite's current y position. |
boolean |
isAlive()
The ship is alive if it's state is STATE_NORMAL or STATE_SHOOTING. |
void |
setState(int state)
Sets the state of this SPRITE to STATE_NORMAL, STATE_SHOOTING, STATE_EXPLODING or STATE_DEAD. |
void |
setVelocityX(float dx)
Sets the horizontal velocity of this Sprite in pixels per millisecond. |
void |
setVelocityY(float dy)
Sets the vertical velocity of this Sprite in pixels per millisecond. |
void |
setX(float x)
Sets this Sprite's current x position. |
void |
setY(float y)
Sets this Sprite's current y position. |
void |
update(long elapsedTime)
Updates this Sprite's Animation and its position based on the velocity. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int STATE_NORMAL
public static final int STATE_DEAD
public static final int STATE_EXPLODING
public static final int STATE_SHOOTING
Animation anim
private float x
private float y
private float dx
private float dy
private int state
| Constructor Detail |
|---|
public Sprite(Animation anim)
anim - Animation| Method Detail |
|---|
public void update(long elapsedTime)
elapsedTime - the time elapsed since the last update in mspublic final float getX()
public final float getY()
public final void setX(float x)
x - x positionpublic final void setY(float y)
y - y positionpublic final int getWidth()
public final int getHeight()
public final float getVelocityX()
public final float getVelocityY()
public final void setVelocityX(float dx)
dx - see abovepublic final void setVelocityY(float dy)
dy - see abovepublic final java.awt.Image getImage()
public java.lang.Object clone()
clone in class java.lang.Objectpublic final int getState()
public void setState(int state)
state - current statepublic final boolean isAlive()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||