|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.huguesjohnson.tiamat.graphics.Sprite
public class Sprite
class Sprite - animated sprite
| Field Summary | |
|---|---|
static int |
DIRECTION_DOWN
DIRECTION constants specify the valid directions a Sprite can travel. |
static int |
DIRECTION_LEFT
DIRECTION constants specify the valid directions a Sprite can travel. |
static int |
DIRECTION_RIGHT
DIRECTION constants specify the valid directions a Sprite can travel. |
static int |
DIRECTION_UP
DIRECTION constants specify the valid directions a Sprite can travel. |
| Constructor Summary | |
|---|---|
Sprite(int direction,
int x,
int y,
java.lang.String absoluteDir,
java.lang.String[][] imagePaths,
java.awt.Component canvas)
Creates a new instance of Sprite. |
|
| Method Summary | |
|---|---|
void |
draw()
Draw the entire object. |
void |
draw(int x,
int y)
Draws the entire map at location specified by (x,y). |
void |
draw(int x1,
int y1,
int x2,
int y2)
Draws the map within the boundaries specified by (x1,y1) and (x2,y2). |
java.awt.Component |
getCanvas()
Returns the canvas where this Sprite is drawn. |
java.awt.image.BufferedImage |
getCurrentImage()
Returns the current image (frame) of animation for this Sprite. |
int |
getDirection()
Returns the direction the sprite is facing, see DIRECTION constants. |
Sprite |
getFollower()
A follower is a reference to another Sprite that follows this Sprite. |
java.awt.image.BufferedImage |
getImage(int direction,
int step)
Returns an image (frame) of animation. |
java.lang.String[][] |
getImagePaths()
Returns the paths to the images that comprise this Sprite. |
java.lang.String[][] |
getImagePathsAbsolute()
Returns the absolute paths to the images that comprise this Sprite. |
boolean |
getIsMoving()
Returns whether this sprite is currently moving. |
boolean |
getMovable()
Returns whether this Sprite can be moved. |
int |
getStepIndex()
Returns the step (frame) of animation is this sprite in. |
int |
getX()
Returns the x-coordinate of this Sprite. |
int |
getY()
Returns the y-coordinate of this Sprite. |
boolean |
importImageData(java.lang.String[][] imagePaths)
Imports image data, returns success of the operation. |
void |
move(int direction)
Moves the sprite in the specified direction. |
void |
onDeserialize(Formatter formatter,
java.lang.String absoluteDir)
The onDeserialize event should be fired after an object is de-serialized. |
void |
setAbsoluteDir(java.lang.String absoluteDir)
Sets the absolute path to the directory where images are stored. |
void |
setCanvas(java.awt.Component canvas)
Sets the canvas where this Sprite is drawn. |
void |
setDirection(int direction)
Sets the direction the sprite is facing, see DIRECTION constants. |
void |
setFollower(Sprite sprite)
A follower is a reference to another Sprite that follows this Sprite. |
void |
setImage(int direction,
int step,
java.lang.String imagePath)
Sets an image (frame) of animation. |
void |
setIsMoving(boolean isMoving)
Sets whether this sprite is currently moving. |
void |
setMovable(boolean movable)
Sets whether this Sprite can be moved. |
void |
setStepIndex(int stepIndex)
Sets the step (frame) of animation is this sprite in. |
void |
setX(int x)
Sets the x-coordinate of this Sprite. |
void |
setY(int y)
Sets the y-coordinate of this Sprite. |
java.lang.String |
toString()
Returns a string representation of the object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int DIRECTION_UP
public static final int DIRECTION_DOWN
public static final int DIRECTION_LEFT
public static final int DIRECTION_RIGHT
| Constructor Detail |
|---|
public Sprite(int direction,
int x,
int y,
java.lang.String absoluteDir,
java.lang.String[][] imagePaths,
java.awt.Component canvas)
direction - The new direction the sprite is facing.x - The new x-coordinate of this Sprite.y - The new y-coordinate of this Sprite.absoluteDir - The absolute path to the directory where images are stored.imagePaths - The paths to the images that comprise this Sprite. Relative to baseImagePath.canvas - The canvas where this Sprite is drawn.| Method Detail |
|---|
public int getDirection()
public void setDirection(int direction)
direction - The new direction the sprite is facing.public int getStepIndex()
public void setStepIndex(int stepIndex)
stepIndex - The new step (frame) of animation is this sprite in.public int getX()
public void setX(int x)
x - The new x-coordinate of this Sprite.public int getY()
public void setY(int y)
y - The new y-coordinate of this Sprite.public boolean getMovable()
public void setMovable(boolean movable)
movable - Whether this Sprite can be moved.public java.lang.String[][] getImagePaths()
public java.lang.String[][] getImagePathsAbsolute()
public java.awt.image.BufferedImage getCurrentImage()
public java.awt.image.BufferedImage getImage(int direction,
int step)
direction - The direction of the image.step - The step index of the image.
public void setImage(int direction,
int step,
java.lang.String imagePath)
direction - The direction of the image.step - The step index of the image.imagePath - The path to the image file, relative to baseImagePath.public void setAbsoluteDir(java.lang.String absoluteDir)
absoluteDir - The absolute path to the directory where images are stored.public Sprite getFollower()
public void setFollower(Sprite sprite)
sprite - The new follower to this Sprite.public java.awt.Component getCanvas()
public void setCanvas(java.awt.Component canvas)
canvas - The canvas where this Sprite is drawn.public void setIsMoving(boolean isMoving)
isMoving - Whether this sprite is currently moving.public boolean getIsMoving()
public boolean importImageData(java.lang.String[][] imagePaths)
imagePaths - The paths to the images that comprise this Sprite. Relative to baseImagePath.
public void move(int direction)
direction - The direction to move the Sprite.public void draw()
Drawable
draw in interface Drawable
public void draw(int x,
int y)
Drawable
draw in interface Drawablex - The x co-ordinate.y - The y co-ordinate.
public void draw(int x1,
int y1,
int x2,
int y2)
Drawable
draw in interface Drawablex1 - The x co-ordinate to start at.y1 - The y co-ordinate to start at.x2 - The x co-ordinate to end at.y2 - The y co-ordinate to end at.public java.lang.String toString()
toString in class java.lang.Object
public void onDeserialize(Formatter formatter,
java.lang.String absoluteDir)
onDeserialize in interface Storableformatter - the formatter to use to load any storable membersabsoluteDir - the working directory since all paths stored in the object should be relative
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||