All Packages This Package Previous Next Index
Class gamelet.Actor
java.lang.Object
|
+----gamelet.Actor
- public abstract class Actor
- extends Object
-
Actor(Gamelet)
- Initializes the actor
-
bounceOff(Actor)
- Bounce off the specified Actor.
-
calculateCurrentFrame()
- Calculates the current frame.
-
calculateNewPosition()
- Calculates the new X and Y position based on velocity and time.
-
checkForOutOfBounds()
- Check for out of bounds and wrap if it is.
-
collideWithActor(Actor)
- Override this method to handle the case when Actor collides with another.
-
draw(Graphics)
- Each Actor is handed a g and is expected to draw itself in it.
-
getCurrentFrame()
- return current frame index which will be displayed next.
-
getGamelet()
-
Return the Gamelet.
-
getHeight()
- return height of actor image.
-
getNumFrames()
- Return the number of frames, the actor image consists of.
-
getWidth()
- return width of actor image.
-
getWrapAround()
- Get current wraparound behaviour.
-
getXPos()
- get x Position of this actor.
-
getXVelocity()
- Get Velocity in X Dimension.
-
getYPos()
- get y position of this actor.
-
getYVelocity()
- Get Velocity in Y Dimension.
-
setCurrentFrame(int)
- set the current frame index.
-
setImage(Image)
- Set the image used for animation.
-
setImage(Image, int, int)
- Set the image used for animation.
-
setImage(Image, int, int, int, int)
- Set the image used for animation.
-
setWrapAround(boolean)
- Change wraparound behaviour.
-
setXPos(double)
- set x Position of this actor.
-
setXVelocity(double)
- Set Velocity in X Dimension.
-
setYPos(double)
- set y position of this actor.
-
setYVelocity(double)
- Set Velocity in Y Dimension.
Actor
public Actor(Gamelet theOwner)
- Initializes the actor
- Parameters:
- theOwner - the gamelet, in which the actor should be
located. This parameter can later be extracted by the
getGamelet() Method.
getXPos
public double getXPos()
- get x Position of this actor.
Position refers to upper left corner of the actor image.
setXPos
public void setXPos(double new_x)
- set x Position of this actor.
Position refers to upper left corner of the actor image.
getYPos
public double getYPos()
- get y position of this actor.
Position refers to upper left corner of the actor image.
setYPos
public void setYPos(double new_y)
- set y position of this actor.
Position refers to upper left corner of the actor image.
getWidth
public double getWidth()
- return width of actor image. This is computed by the setImage()-Methods.
getHeight
public double getHeight()
- return height of actor image. This is computed by the setImage()-Methods.
getCurrentFrame
public int getCurrentFrame()
- return current frame index which will be displayed next.
setCurrentFrame
public void setCurrentFrame(int new_currentFrame)
- set the current frame index. This is the index of the frame, which will be displayed next.
getNumFrames
public int getNumFrames()
- Return the number of frames, the actor image consists of.
This is computed by the setImage()-Methods.
getWrapAround
public boolean getWrapAround()
- Get current wraparound behaviour.
When wraparound is on, actors which will move past one border
will apear again on the other side after a while. When wraparound
is switched off, you are responsible to check that the actor will
remain inside the visible area.
setWrapAround
public void setWrapAround(boolean new_wrapAround)
- Change wraparound behaviour.
When wraparound is on, actors which will move past one border
will apear again on the other side after a while. When wraparound
is switched off, you are responsible to check that the actor will
remain inside the visible area.
getGamelet
public Gamelet getGamelet()
- Return the Gamelet.
Through this method, the width and height of the visible area can
be extracted. Also, new actors can be added or existing ones removed.
getXVelocity
public double getXVelocity()
- Get Velocity in X Dimension.
The unit of the velocity is screen pixels per second. The position is
updated in regular intervals using this velocity.
setXVelocity
public void setXVelocity(double new_vel_x)
- Set Velocity in X Dimension.
The unit of the velocity is screen pixels per second. The position is
updated in regular intervals using this velocity.
getYVelocity
public double getYVelocity()
- Get Velocity in Y Dimension.
The unit of the velocity is screen pixels per second. The position is
updated in regular intervals using this velocity.
setYVelocity
public void setYVelocity(double new_vel_y)
- Set Velocity in Y Dimension.
The unit of the velocity is screen pixels per second. The position is
updated in regular intervals using this velocity.
setImage
protected void setImage(Image theImage,
int frameXSize,
int frameYSize,
int framesHorizontally,
int totalFrames)
- Set the image used for animation.
setImage
protected void setImage(Image theImage)
- Set the image used for animation. Good for an image that has all frames
within it and none empty.
setImage
protected void setImage(Image theImage,
int horizontalFrames,
int totalFrames)
- Set the image used for animation. Good for an image that has some empty
frames within it.
calculateNewPosition
protected void calculateNewPosition()
- Calculates the new X and Y position based on velocity and time. Also may check if
Actor needs to wrap around at the edges if the wraparound flag is set.
calculateCurrentFrame
protected void calculateCurrentFrame()
- Calculates the current frame. Behaviour is to flip through frames sequentially
and loop.
checkForOutOfBounds
protected void checkForOutOfBounds()
- Check for out of bounds and wrap if it is. This is called automatically
if wrapAround is set to true with method setWrapAround().
draw
public void draw(Graphics g)
- Each Actor is handed a g and is expected to draw itself in it.
collideWithActor
protected void collideWithActor(Actor theActor)
- Override this method to handle the case when Actor collides with another.
bounceOff
public void bounceOff(Actor theActor)
- Bounce off the specified Actor. Changes it's velocity so that it appears
to bounce off.
All Packages This Package Previous Next Index