|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jtgl.gaming.Surface
org.jtgl.gaming.Sprite
public class Sprite
Sprite class
Field Summary | |
---|---|
static int |
COLLISION_BOTTOM
Constant signalling collision with bottom side of lastCollidedRect. |
static int |
COLLISION_BOTTOM_LEFT
Constant signalling collision with a bottom left corner side of lastCollidedRect. |
static int |
COLLISION_BOTTOM_RIGHT
Constant signalling collision with a bottom left corner side of lastCollidedRect. |
static int |
COLLISION_LEFT
Constant signalling collision with left side of lastCollidedRect. |
static int |
COLLISION_RIGHT
Constant signalling collision with right side of lastCollidedRect. |
static int |
COLLISION_TOP
Constant signalling collision with top side of lastCollidedRect. |
static int |
COLLISION_TOP_LEFT
Constant signalling collision with a top left corner side of lastCollidedRect. |
static int |
COLLISION_TOP_RIGHT
Constant signalling collision with a top left corner side of lastCollidedRect. |
boolean |
debugCollisionRect
|
Constructor Summary | |
---|---|
Sprite(ImageMatrix matrix)
Creates an animated Sprite using a ImageMatrix |
|
Sprite(int width,
int height)
Creates a Sprite surface (Use only for subclasses) |
|
Sprite(JTGLImage staticImage)
Creates a non animated Sprite using the provided image |
|
Sprite(JTGLImage image,
int frameWidth,
int frameHeight)
Creates an animated Sprite using the frames from provided image |
|
Sprite(Sprite sprite)
Creates a Sprite from another one |
Method Summary | |
---|---|
void |
action(long currentTimeMs)
Performs a timely action by calling performTimedAction . |
void |
animate(long currentTimeMs)
|
protected boolean |
checkTileCollision(TiledSurface tiledSurface,
int col,
int row)
Checks where this Sprite collides with surrounding tiles. |
boolean |
collidesAtWith(int tx,
int ty,
int x,
int y,
int width,
int height)
|
boolean |
collidesAtWith(int tx,
int ty,
JTGLRect rect)
|
boolean |
collidesAtWith(int tx,
int ty,
Sprite sprite)
|
boolean |
collidesAtWith(int tx,
int ty,
Surface surface)
|
boolean |
collidesAtWith(int x,
int y,
TiledSurface tiledSurface)
|
boolean |
collidesAtWithBounds(int tx,
int ty,
int x,
int y,
int width,
int height)
|
boolean |
collidesAtWithBounds(int tx,
int ty,
JTGLRect rect)
|
boolean |
collidesAtWithBounds(int tx,
int ty,
Sprite sprite)
|
boolean |
collidesAtWithBounds(int tx,
int ty,
Surface surface)
|
boolean |
collidesWith(int x,
int y,
int width,
int height)
|
boolean |
collidesWith(int x,
int y,
TiledSurface tiledSurface,
boolean saveCollidedRect)
Test if this Sprite collides at location (x,y) with a non-empty cell from a TiledSurface instance |
boolean |
collidesWith(JTGLRect rect)
|
boolean |
collidesWith(Sprite sprite)
|
boolean |
collidesWith(Surface surface)
|
boolean |
collidesWith(TiledSurface tiledSurface)
|
boolean |
collidesWith(TiledSurface tiledSurface,
boolean saveCollidedRect)
|
boolean |
collidesWithBounds(int x,
int y,
int width,
int height)
|
boolean |
collidesWithBounds(JTGLRect rect)
|
boolean |
collidesWithBounds(Sprite sprite)
|
boolean |
collidesWithBounds(Surface surface)
|
void |
draw(JTGLGraphics g)
|
JTGLRect |
getAbsCollisionRectangle()
|
long |
getActionDelay()
|
TimeTrigger |
getActionTrigger()
|
long |
getAnimationDelay()
|
TimeTrigger |
getAnimationTrigger()
|
JTGLRect |
getCollisionRectangle()
|
int |
getFrame()
|
int |
getFrameSequenceLength()
|
int |
getLastCollidedCol()
|
JTGLRect |
getLastCollidedRect()
|
int |
getLastCollidedRow()
|
int |
getLastCollisionLocation()
Detects where occurred last collision within a Rect bounds (border limit only!) |
int |
getMoveX()
|
int |
getMoveY()
|
int |
getRawFrameCount()
|
int |
getSpeed()
|
void |
incSpeed(int amount)
|
boolean |
isActionEnabled()
|
boolean |
isAnimationEnabled()
|
boolean |
isLocationValid()
Default position validation function. |
void |
move()
Moves this sprite by moveX ,moveY . |
boolean |
moveRefTo(int x,
int y,
boolean doValidate)
Moves the sprite toward the specified position. |
void |
nextFrame()
|
protected void |
performTimedAction(long currentTimeMs)
Perform actions every actionDelay delay
By default moves this sprite by moveX ,moveY . |
protected void |
performTimedAnimation(long currentTimeMs)
|
boolean |
preCollidesWith(TiledSurface tiledSurface)
|
boolean |
preCollidesWithBounds(int x,
int y,
int width,
int height)
|
boolean |
preCollidesWithBounds(JTGLRect rect)
|
boolean |
preCollidesWithBounds(Sprite sprite)
|
boolean |
preCollidesWithBounds(Surface surface)
|
void |
prevFrame()
|
void |
setActionDelay(long delay)
|
void |
setActionEnabled(boolean enabled)
|
void |
setAnimationDelay(long delay)
|
void |
setAnimationEnabled(boolean enabled)
|
void |
setCollisionRectangle(int x,
int y,
int width,
int height)
|
void |
setFrame(int sequenceIndex)
|
void |
setInitSequence()
|
void |
setMove(int moveX,
int moveY)
|
void |
setSequence(int[] newSequence)
|
void |
setSpeed(int speed)
|
Methods inherited from class org.jtgl.gaming.Surface |
---|
getAbsRefLocation, getBounds, getCenterLocation, getHeight, getLocation, getRefLocation, getWidth, getX, getY, isVisible, move, setAbsRefLocation, setLocation, setRefLocation, setVisible |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int COLLISION_TOP
lastCollidedRect
,
getLastCollidedRect
,
getLastCollisionLocation
,
Constant Field Valuespublic static final int COLLISION_BOTTOM
lastCollidedRect
,
getLastCollidedRect
,
getLastCollisionLocation
,
Constant Field Valuespublic static final int COLLISION_LEFT
lastCollidedRect
,
getLastCollidedRect
,
getLastCollisionLocation
,
Constant Field Valuespublic static final int COLLISION_RIGHT
lastCollidedRect
,
getLastCollidedRect
,
getLastCollisionLocation
,
Constant Field Valuespublic static final int COLLISION_TOP_LEFT
lastCollidedRect
,
getLastCollidedRect
,
getLastCollisionLocation
,
Constant Field Valuespublic static final int COLLISION_TOP_RIGHT
lastCollidedRect
,
getLastCollidedRect
,
getLastCollisionLocation
,
Constant Field Valuespublic static final int COLLISION_BOTTOM_LEFT
lastCollidedRect
,
getLastCollidedRect
,
getLastCollisionLocation
,
Constant Field Valuespublic static final int COLLISION_BOTTOM_RIGHT
lastCollidedRect
,
getLastCollidedRect
,
getLastCollisionLocation
,
Constant Field Valuespublic boolean debugCollisionRect
Constructor Detail |
---|
public Sprite(int width, int height)
public Sprite(JTGLImage staticImage)
public Sprite(ImageMatrix matrix)
public Sprite(JTGLImage image, int frameWidth, int frameHeight)
public Sprite(Sprite sprite)
Method Detail |
---|
public final void setSpeed(int speed)
public final int getSpeed()
public final void incSpeed(int amount)
public final void setMove(int moveX, int moveY)
public final int getMoveX()
public final int getMoveY()
public void setActionDelay(long delay)
public long getActionDelay()
public void setActionEnabled(boolean enabled)
public boolean isActionEnabled()
public TimeTrigger getActionTrigger()
public void action(long currentTimeMs)
performTimedAction
.
protected void performTimedAction(long currentTimeMs)
actionDelay
delay
By default moves this sprite by moveX
,moveY
.
Subclases may override this method in order to perform any desired action(s).
public final void move()
moveX
,moveY
.
public void setAnimationDelay(long delay)
public long getAnimationDelay()
public void setAnimationEnabled(boolean enabled)
public boolean isAnimationEnabled()
public TimeTrigger getAnimationTrigger()
public void animate(long currentTimeMs)
protected void performTimedAnimation(long currentTimeMs)
public void setSequence(int[] newSequence)
public void setInitSequence()
public void setFrame(int sequenceIndex)
public final int getFrame()
public int getRawFrameCount()
public int getFrameSequenceLength()
public void nextFrame()
public void prevFrame()
public void setCollisionRectangle(int x, int y, int width, int height)
public JTGLRect getCollisionRectangle()
public JTGLRect getAbsCollisionRectangle()
public JTGLRect getLastCollidedRect()
public int getLastCollidedCol()
public int getLastCollidedRow()
public int getLastCollisionLocation()
public boolean collidesWith(int x, int y, int width, int height)
public boolean collidesAtWith(int tx, int ty, int x, int y, int width, int height)
public boolean collidesWith(JTGLRect rect)
public boolean collidesAtWith(int tx, int ty, JTGLRect rect)
public boolean collidesWith(Surface surface)
public boolean collidesAtWith(int tx, int ty, Surface surface)
public boolean collidesWith(Sprite sprite)
public boolean collidesAtWith(int tx, int ty, Sprite sprite)
public boolean collidesWith(TiledSurface tiledSurface)
public boolean collidesWith(TiledSurface tiledSurface, boolean saveCollidedRect)
public boolean preCollidesWith(TiledSurface tiledSurface)
public boolean collidesAtWith(int x, int y, TiledSurface tiledSurface)
public boolean collidesWith(int x, int y, TiledSurface tiledSurface, boolean saveCollidedRect)
TiledSurface
instance
protected boolean checkTileCollision(TiledSurface tiledSurface, int col, int row)
public boolean preCollidesWithBounds(int x, int y, int width, int height)
public boolean collidesWithBounds(int x, int y, int width, int height)
public boolean collidesAtWithBounds(int tx, int ty, int x, int y, int width, int height)
public boolean preCollidesWithBounds(JTGLRect rect)
public boolean collidesWithBounds(JTGLRect rect)
public boolean collidesAtWithBounds(int tx, int ty, JTGLRect rect)
public boolean preCollidesWithBounds(Surface surface)
public boolean collidesWithBounds(Surface surface)
public boolean collidesAtWithBounds(int tx, int ty, Surface surface)
public boolean preCollidesWithBounds(Sprite sprite)
public boolean collidesAtWithBounds(int tx, int ty, Sprite sprite)
public boolean collidesWithBounds(Sprite sprite)
public boolean isLocationValid()
moveRefTo(int, int, boolean)
public boolean moveRefTo(int x, int y, boolean doValidate)
x
- position.y
- position.doValidate
- if true the position is validated which means that the
isLocationValid() function is called.isLocationValid()
public void draw(JTGLGraphics g)
draw
in class Surface
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |