|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmhframework.MHActor
public class MHActor
Base class for creating interactive or autonomous game actors.
Constructor Summary | |
---|---|
MHActor()
Constructor. |
Method Summary | |
---|---|
void |
advance()
Updates the actor's animation frame number, location, and rotation. |
int |
getAnimationSequenceNumber()
Returns the actor's current action, which is also the number of the actor's current animation sequence. |
java.awt.geom.Rectangle2D |
getBounds()
Calculates and returns the bounding rectangle for this actor's current sprite image without regard to scaling. |
double |
getCenterX()
|
double |
getCenterY()
|
int |
getFrameCount()
|
int |
getFrameNumber()
|
int |
getFrameTimer()
Returns the frameTimer. |
int |
getHealth()
Returns this actor's current health value |
int |
getHeight()
|
double |
getHorizontalSpeed()
Returns the horizontal speed value for this actor. |
java.awt.Image |
getImage()
Returns current animation frame. |
MHImageGroup |
getImageGroup()
|
int |
getMaxHealth()
Returns this actor's maximum health value |
double |
getRotation()
|
double |
getRotationSpeed()
|
double |
getScale()
|
java.awt.geom.Rectangle2D |
getScaledBounds()
Calculates and returns the bounding rectangle for this actor's current sprite image at its current scale. |
double |
getSpeed()
|
double |
getVerticalSpeed()
Returns the vertical speed value for this actor. |
int |
getWidth()
|
double |
getX()
Returns the x coordinate of this actor's left edge |
double |
getY()
Returns the y coordinate of this actor's top side |
boolean |
isAnimationFinished()
|
void |
render(java.awt.Graphics2D g)
Draws the actor onto the sent graphics object based on its current action, animation frame number, and (x, y) coordinates |
void |
render(java.awt.Graphics2D g,
int rx,
int ry)
Draws the actor onto the sent graphics object at the (x, y) coordinates specified by rx and ry. |
void |
setAnimationSequence(int action)
Sets the actor's action. |
void |
setFrameNumber(int frameNumber)
|
void |
setFrameTimer(int frameTimer)
Sets the value of the frame timer. |
void |
setHealth(int health)
|
void |
setHorizontalSpeed(double speed)
Sets the horizontal movement speed of this actor. |
void |
setImageGroup(MHImageGroup ig)
Assigns an existing MHImageGroup to this actor. |
void |
setLocation(double px,
double py)
Positions the actor at the coordinates specified by the input (x, y) parameters. |
void |
setMaxHealth(int max)
Sets the maximum health value for this actor. |
void |
setRotation(double rotation)
|
void |
setRotationSpeed(double rotationSpeed)
|
void |
setScale(double scale)
|
void |
setSpeed(double speed)
|
void |
setVerticalSpeed(double speed)
Sets the vertical movement speed of this actor. |
void |
setX(double px)
Sets the x. |
void |
setY(double py)
Sets the y. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MHActor()
Method Detail |
---|
public void setHorizontalSpeed(double speed)
speed
- The number of pixels to move left or right on
each iteration of the game loop. A positive
input causes the actor to move to the right, and
a negative input causes movement to the left.public double getHorizontalSpeed()
public double getVerticalSpeed()
public void setVerticalSpeed(double speed)
speed
- The number of pixels to move up or down on each
iteration of the game loop. A positive input causes the
actor to go down, and a negative input causes it to go up.public void setMaxHealth(int max)
max
- The maximum health value for this actorpublic int getMaxHealth()
public int getHealth()
public void setHealth(int health)
health
- the health to setpublic void render(java.awt.Graphics2D g)
render
in interface MHRenderable
g
- The Graphics object on which to draw the actorpublic void render(java.awt.Graphics2D g, int rx, int ry)
g
- The Graphics object on which to draw the actorpublic java.awt.Image getImage()
public void advance()
advance
in interface MHRenderable
public final void setImageGroup(MHImageGroup ig)
ig
- A reference to an existing MHImageGroup object.public MHImageGroup getImageGroup()
public java.awt.geom.Rectangle2D getBounds()
public int getWidth()
public int getHeight()
public java.awt.geom.Rectangle2D getScaledBounds()
public double getCenterX()
public double getCenterY()
public int getFrameTimer()
public int getFrameCount()
public double getX()
public double getY()
public void setFrameTimer(int frameTimer)
frameTimer
- The frameTimer to setpublic void setX(double px)
px
- The x to setpublic void setY(double py)
py
- The y to setpublic void setLocation(double px, double py)
px
- The x coordinate at which to position the actorpy
- The y coordinate at which to position the actorpublic int getAnimationSequenceNumber()
public void setAnimationSequence(int action)
action
- The action to setpublic int getFrameNumber()
public void setFrameNumber(int frameNumber)
frameNumber
- The frame number to set.public boolean isAnimationFinished()
public double getScale()
public void setScale(double scale)
scale
- the scale to setpublic double getRotation()
public void setRotation(double rotation)
public double getRotationSpeed()
public void setRotationSpeed(double rotationSpeed)
public double getSpeed()
public void setSpeed(double speed)
speed
- the speed to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |