|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectandroid.gameengine.icadroids.objects.GameObject
public class GameObject
GameObject is a (not moving) object with a lot of useful methods in it. You can bind a sprite on it, activate alarms, get the size, position, etc. Don't forget to add the GameObject to the game with 'addGameObject'!
Field Summary | |
---|---|
Rect |
position
The bounding rectangle that contains the sprite on the screen |
protected double |
xlocation
The exact x position of the upper left corner of the object. |
protected double |
ylocation
the exact y position of the upper left corner of the object. |
Constructor Summary | |
---|---|
GameObject()
|
Method Summary | |
---|---|
void |
clearActive()
Mark an object as 'dead', to be removed at end of cycle. |
void |
deleteThisGameObject()
Delete the GameObject. |
void |
drawCustomObjects(Canvas canvas)
Override this method to draw your own text, rectangle and other objects on the screen (like a game dashboard). |
void |
drawGameObject(Canvas canvas)
Override this method to implement your own rendered canvas objects like text, rectangles or colors. |
double |
getAngle(GameObject object)
Use this function to get the angle between you and another object. |
float |
getCenterX()
Get the center x of the GameObject |
float |
getCenterY()
Get the center y of the GameObject |
float |
getDepth()
Get the depth of the object in rendering. |
int |
getFrameHeight()
Get the frame height of the object's sprite, this will be also the height of the object in the game. |
int |
getFrameWidth()
Get the frame width of the object's sprite, this will be also the width of the object in the game. |
double |
getFullX()
Get the exact x position of the GameObject |
double |
getFullY()
Get the exact y position of the GameObject |
Rect |
getPosition()
Get the sprite position as rectangle |
AnimatedSprite |
getSprite()
Get the sprite Object of the GameObject |
int |
getX()
Get the x position on the screen, rounds the exact X-pos to an int. |
int |
getY()
Get the y position on the screen, rounds the exact Y-pos to an int. |
void |
intialize()
Called when the application starts. |
void |
intializeGameObject()
Initialize resources. |
boolean |
isActive()
Ask if an object is still alive, that is: it hasn't been deleted from the game or added in this cycle of the game. |
boolean |
isVisible()
Ask if an object is visible |
void |
jumpToStartPosition()
Jump to the object's start position Note: this only works when a start position is set, this happens automatically when 'addGameObject' is called. |
void |
setAnimationSpeed(int speed)
Set the speed of the sprite animation. |
void |
setDepth(float depth)
Set the depth of the object in rendering. |
void |
setFrameNumber(int number)
Set the frame number of the sprite. |
void |
setPosition(double x,
double y)
Set the position on the screen. |
void |
setSprite(AnimatedSprite theSprite)
Set a sprite for the GameObject. |
void |
setSprite(java.lang.String resourceName)
Set a sprite for the GameObject. |
void |
setSprite(java.lang.String resourceName,
int numberOfFrames)
Set a sprite for the GameObject. |
void |
setStartPosition(int x,
int y)
Set a (new) start position which the objects jumps to when using 'jumpToStartPosition()'. |
void |
setVisibility(boolean visible)
Set the visibility of the GameOject. |
void |
setX(double x)
Set x position of the GameObject WARNING: Do NOT use this method to move the player or a lot of methods will behave incorrectly. |
void |
setY(double y)
Set y position of the GameObject. |
void |
startAnimate()
Start animating the sprite, from the current frame |
void |
stopAnimate()
Stop animating the sprite. |
void |
update()
The update-method will be called every cycle of the game loop. |
protected void |
updatePlayerFramePosition()
Update position rectangle used for drawing the sprite on the right position with the right size on the screen. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected double xlocation
protected double ylocation
public Rect position
Constructor Detail |
---|
public GameObject()
Method Detail |
---|
public final void intializeGameObject()
public void intialize()
public boolean isActive()
public boolean isVisible()
public void clearActive()
public void update()
public void drawGameObject(Canvas canvas)
canvas
- The Android canvas. Use this provided object to
draw for example text, rectangles and colors. For the api see:
http://developer.android.com/reference/android/graphics/Canvas.htmlpublic void drawCustomObjects(Canvas canvas)
canvas
- The Android canvas. Use this provided object to
draw for example text, rectangles and colors. For the api see:
http://developer.android.com/reference/android/graphics/Canvas.htmlprotected void updatePlayerFramePosition()
public final void setSprite(java.lang.String resourceName)
resourceName
- The name of the resource in the /res/drawable folder
without extension , so when your picture in the
/res/drawable is named 'picture.jpg', this parameter should be
"picture" .public final void setSprite(java.lang.String resourceName, int numberOfFrames)
resourceName
- The name of the resource in the /res/drawable folder
without extension , so when your picture in the
/res/drawable is named 'picture.jpg', this parameter should be
"picture" .numberOfFrames
- The number of frames in the strippublic final void setSprite(AnimatedSprite theSprite)
theSprite
- AnimatedSprite that has been created earlierpublic final void startAnimate()
public final void stopAnimate()
public final int getX()
public final int getY()
public final float getCenterX()
public final float getCenterY()
public final double getFullX()
public final double getFullY()
public final void setX(double x)
x
- The x positionpublic final void setY(double y)
y
- The y positionpublic final void setPosition(double x, double y)
x
- The x positiony
- The y positionpublic final AnimatedSprite getSprite()
public final int getFrameWidth()
public final int getFrameHeight()
public final Rect getPosition()
public final void setAnimationSpeed(int speed)
speed
- The number of game loops that must occur before the next
frame, so higher speed is slower animation. 0 stops animation.public final void setFrameNumber(int number)
number
- The frame number, frame numbers range from 0 to NrOfFrames-1public final void deleteThisGameObject()
public final void setVisibility(boolean visible)
visible
- True for visible, false for invisiblepublic void jumpToStartPosition()
public void setStartPosition(int x, int y)
x
- The start X positiony
- The start Y positionpublic final double getAngle(GameObject object)
object
- an instance of another object to calculate the angle for.
public float getDepth()
public void setDepth(float depth)
depth
- the depth, a floatGameEngine.addGameObject(GameObject gameObject, float layerposition)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |