|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectandroid.gameengine.icadroids.objects.GameObject
android.gameengine.icadroids.objects.MoveableGameObject
public class MoveableGameObject
MoveableGameObject represents a moveable object in the game. Make sure to add
the MoveableGameObject to the object list, else it won't update.
The game engine does collision detection for MoveableGameItems. This is very
time consuming, so make sure you only extend this class when the items are
really moving!
note: Tile collision only works when the object is moving!
Field Summary |
---|
Fields inherited from class android.gameengine.icadroids.objects.GameObject |
---|
position, xlocation, ylocation |
Constructor Summary | |
---|---|
MoveableGameObject()
|
Method Summary | ||
---|---|---|
void |
bounce(boolean horizontal)
Bounces the object , what this does is reversing the horizontal or vertical direction. |
|
void |
bounce(TileCollision tc)
Bounce at the tile this object has just collided into. |
|
|
collidedWith(java.lang.Class<T> objectClass)
Checks if your object has collided with another object of a certain class. |
|
java.util.ArrayList<GameObject> |
getCollidedObjects()
Checks wether or not this gameObject has collided with one or multiple GameObjects or MovableGameObjects. |
|
CollidingObject |
getCollidingObject()
Get the colliding object if you want to make use of the methods that are in there |
|
double |
getDirection()
Gets the direction of the objects movement in degrees. |
|
double |
getDirectionRadians()
Gets the direction of the objects movement in radians. |
|
double |
getFriction()
Gets the friction of this object |
|
double |
getPrevCenterX()
Gets the previous centerX position of this object, which is saved every loop. |
|
double |
getPrevCenterY()
Gets the previous centerY position of this object, which is saved every loop. |
|
double |
getPrevX()
Gets the previous X position of this object, which is saved every loop. |
|
double |
getPrevY()
Gets the previous Y position of this object, which is saved every loop. |
|
double |
getSpeed()
Gets the speed of this object. |
|
Tile |
getTileOnPosition(int xPosition,
int yPosition)
Get a tile on a specific x and y position in the game world. |
|
double |
getxSpeed()
Gets the X speed of this object. |
|
double |
getySpeed()
Gets the Y speed of this object. |
|
void |
movePlayer(int x_movement,
int y_movement)
This function allows you to move this object by specifying the x and y. |
|
boolean |
movesDown()
|
|
boolean |
movesLeft()
|
|
boolean |
movesRight()
|
|
boolean |
movesUp()
|
|
void |
moveTowardsAPoint(double x,
double y)
Sets the objects direction to move towards target point. |
|
void |
moveUpToTileSide(TileCollision tc)
Move as close as possible to the side of tile, as specified in the TileCollision object, using the direction that the GameObject already has Note: Using Tiles that are not involved in a collision or are not close to the object can cause strange behaviour: The GameObject is moved to the extended line that passes through the specified side of the tile, using the original direction of the object's speed. |
|
void |
outsideWorld()
Triggered when the MoveableGameObject moves outside of the world. |
|
void |
reverseHorizontalDirection()
Reverses the horizontal direction of the objects movement. |
|
void |
reverseVerticalDirection()
Reverses the vertical direction of the objects movement. |
|
void |
setDirection(double direction)
Sets the direction of this object in degrees Direction 0 points up, directions go clockwise, so 90 is right, etc. |
|
void |
setDirectionRadians(double Direction)
Sets the current direction of this object in radians Direction 0 points up, directions go clockwise, so 0.5*pi is right, etc. |
|
void |
setDirectionSpeed(double direction,
double speed)
Sets both the direction and the speed of this object. |
|
void |
setFriction(double friction)
Sets the friction of this object, that is the amount of speed reduction. |
|
void |
setSpeed(double speed)
Sets the speed of this object |
|
void |
setxSpeed(double xSpeed)
Sets the x speed of this object. |
|
void |
setySpeed(double ySpeed)
Sets the y speed of this object. |
|
void |
undoMove()
This function will reset this object to its previous Position. the Previous Position will is set every loop. |
|
void |
update()
The update-method will be called every cycle of the game loop. |
Methods inherited from class android.gameengine.icadroids.objects.GameObject |
---|
clearActive, deleteThisGameObject, drawCustomObjects, drawGameObject, getAngle, getCenterX, getCenterY, getDepth, getFrameHeight, getFrameWidth, getFullX, getFullY, getPosition, getSprite, getX, getY, intialize, intializeGameObject, isActive, isVisible, jumpToStartPosition, setAnimationSpeed, setDepth, setFrameNumber, setPosition, setSprite, setSprite, setSprite, setStartPosition, setVisibility, setX, setY, startAnimate, stopAnimate, updatePlayerFramePosition |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MoveableGameObject()
Method Detail |
---|
public void update()
update
in class GameObject
GameObject.update()
public final void moveTowardsAPoint(double x, double y)
x
- The x coordinate of your point.y
- The y coordinate of your point.public final void setDirection(double direction)
direction
- the direction in degrees.public final void setSpeed(double speed)
speed
- the speed to give this object.public final void setDirectionSpeed(double direction, double speed)
direction
- the direction you want to set in the degreesspeed
- the speed you want to set.public final void setxSpeed(double xSpeed)
xSpeed
- the xSpeed.public final void setySpeed(double ySpeed)
ySpeed
- the ySpeed.public final void setDirectionRadians(double Direction)
Direction
- the direction in radians.public final void movePlayer(int x_movement, int y_movement)
x_movement
- the amount of X pixels this object should move.y_movement
- the amount of Y pixels this object should move.public final boolean movesLeft()
public final boolean movesRight()
public final boolean movesUp()
public final boolean movesDown()
public final void bounce(boolean horizontal)
horizontal
- Put this on TRUE if you want to bounce Horizontal, FALSE if
you want to bounce vertical.public final void setFriction(double friction)
friction
- the fraction of decrease in speed per cycle of the game loop.
Must be a number between 0 and 1public final double getFriction()
public final double getDirection()
public final double getDirectionRadians()
public final void reverseHorizontalDirection()
public final void reverseVerticalDirection()
public final double getPrevX()
public final double getPrevY()
public final double getPrevCenterX()
public final double getPrevCenterY()
public final double getSpeed()
public final double getxSpeed()
public final double getySpeed()
public final void undoMove()
public void outsideWorld()
public final java.util.ArrayList<GameObject> getCollidedObjects()
public final <T> boolean collidedWith(java.lang.Class<T> objectClass)
objectClass
- Asks for any generic class, classes you should use are
Gameobject,MoveableGameobject or any extensions of these two.
public void moveUpToTileSide(TileCollision tc)
tc
- the TileCollision (usually provided by the the 'collisionOccurred' call )public void bounce(TileCollision tc)
tc
- The TileCollision (that is Tile plus side) you want to bounce ontopublic Tile getTileOnPosition(int xPosition, int yPosition)
xPosition
- x position of the tileyPosition
- y position of the tile
public CollidingObject getCollidingObject()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |