|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjplay.GameObject
jplay.GameImage
jplay.Animation
jplay.Sprite
public class Sprite
Class responsible for controlling all actions and behaviors of sprite.
Field Summary |
---|
Fields inherited from class jplay.GameObject |
---|
height, width, x, y |
Constructor Summary | |
---|---|
Sprite(java.lang.String fileName)
Constructor of the class. |
|
Sprite(java.lang.String fileName,
int numFrames)
Constructor of the class. |
Method Summary | |
---|---|
void |
fall()
This method simulates the gravity. |
int |
getFloor()
Return the value the current floor. |
double |
getGravity()
Returns the value used for gravity. |
double |
getJumpVelocity()
Returns the velocity of jump. |
boolean |
isJumping()
Returns true if the sprite is executing the jump, false otherwise. |
boolean |
isOnFloor()
Returns true if the sprite is on the floor, false otherwise. |
void |
jump()
Makes the sprite jump. |
void |
jump(int jumpKey)
Makes the sprite jump. |
void |
moveTo(double x,
double y,
double velocity)
Moves the sprite from a point to another. |
void |
moveX(double velocity)
Method used to move the sprite by the x-axis. |
void |
moveX(int leftKey,
int rightKey,
double velocity)
Method used to move the sprite by the x-axis. |
void |
moveY(double velocity)
Method used to move the sprite by y-axis. |
void |
moveY(int upKey,
int downKey,
double velocity)
Method used to move the sprite by y-axis. |
void |
setFloor(int floor)
Sets the floor that will be used for the methods jump or fall. |
void |
setGravity(double gravity)
Sets the value for gravity. |
void |
setJumpVelocity(double velocity)
Sets the jump velocity for the sprite. |
Methods inherited from class jplay.Animation |
---|
draw, getCurrFrame, getDuration, getFinalFrame, getInitialFrame, getTotalDuration, hide, isLooping, isPlaying, pause, play, setCurrFrame, setDuration, setFinalFrame, setInitialFrame, setLoop, setSequence, setSequence, setSequenceTime, setSequenceTime, setTotalDuration, stop, unhide, update |
Methods inherited from class jplay.GameImage |
---|
loadImage |
Methods inherited from class jplay.GameObject |
---|
collided |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Sprite(java.lang.String fileName)
fileName
- Path of the file.public Sprite(java.lang.String fileName, int numFrames)
fileName
- Path of the file.numFrames
- number of frames.Method Detail |
---|
public void moveX(double velocity)
velocity
- speed of locomotion in pixels.public void moveX(int leftKey, int rightKey, double velocity)
leftKey
- Key used to move the sprite for the left.rightKey
- Key used to move the sprite for the right.velocity
- speed of locomotion in pixels.public void moveY(double velocity)
velocity
- speed of locomotion in pixels.public void moveY(int upKey, int downKey, double velocity)
upKey
- Key used to move the sprite for the left.downKey
- Key used to move the sprite for the right.velocity
- speed of locomotion in pixels.public void moveTo(double x, double y, double velocity)
x
- Target point on the x axis.y
- Target point on the y axis.velocity
- speed of locomotion in pixels.public void setFloor(int floor)
floor
- Value of the coordinate x.public int getFloor()
public void jump(int jumpKey)
jumpKey
- key used to start the jump.public void jump()
public boolean isJumping()
public void fall()
public boolean isOnFloor()
public void setJumpVelocity(double velocity)
velocity
- speed of locomotion in pixels.public double getJumpVelocity()
public double getGravity()
public void setGravity(double gravity)
gravity
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |