public abstract class GameObject
extends java.lang.Object
Constructor and Description |
---|
GameObject()
Creates a GameObject with a bottom-bottom-center at (0,0) and a rectangle collider with width/height of zero.
|
GameObject(float x,
float y,
float width,
float height)
Creates a GameObject with bottom-center at (x,y) and rectangle collider with given width/height.
|
Modifier and Type | Method and Description |
---|---|
abstract boolean |
canTarget()
Returns true if the GameObject can be targetted by a Human.
|
Vector2 |
getAcceleration()
Retrieves the acceleration of the gameObject as a Vector2.
|
<T extends Collider> |
getCollider()
Returns the collider used by the gameObject for collisions.
|
int |
getObjectId()
Gets the ID of the GameObject, used to identify a GameObject in a specific TerrainLayer.
|
Vector2 |
getPosition()
Retrieves the bottom-center position of the gameObject as a Vector2.
|
Vector2 |
getPreviousPosition()
Returns the GameObject's previous position before the current game tick.
|
com.esotericsoftware.spine.Skeleton |
getSkeleton()
Returns the skeleton used to render the GameObject to the screen.
|
float |
getStateTime()
Gets the amount of time the GameObject has been in a specific state.
|
Cell |
getTerrainCell()
Gets the cell coordinates where the GameObject is placed on the TerrainLevel.
|
Vector2 |
getVelocity()
Retrieves the velocity of the gameObject as a Vector2.
|
float |
getX()
Returns the bottom-center x-position of the GameObject.
|
float |
getY()
Returns the bottom-center y-position of the GameObject.
|
boolean |
isAbove(GameObject gameObject)
Returns true if this GameObject is above the given GameObject.
|
void |
moveTo(float x,
float y,
float time)
Moves the GameObject to the desired (x,y) position in a straight line at the given speed in m/s.
|
void |
setAcceleration(float x,
float y)
Sets the acceleration of the GameObject at their desired (x,y) values.
|
void |
setCollider(Collider c)
Sets the collider used by the gameObject for collisions.
|
void |
setObjectId(int objectId)
Sets the ID of the GameObject, used to identify a GameObject in a specific TerrainLayer.
|
void |
setPosition(float x,
float y)
Sets the bottom-center position of the GameObject at the desired (x,y) coordinates.
|
void |
setSkeleton(com.esotericsoftware.spine.Skeleton skeleton)
Sets the spine skeleton used by the GameObject to be rendered on-screen.
|
void |
setStateTime(float stateTime)
Sets the amount of time the GameObject has been in a specific state.
|
void |
setTerrainCell(int row,
int col)
Sets the cell coordinates where the GameObject is placed on the TerrainLevel.
|
void |
setVelocity(float x,
float y)
Sets the velocity of the GameObject at their desired (x,y) values.
|
void |
setVelocityX(float x)
Updates the x-velocity of the GameObject.
|
void |
setVelocityY(float y)
Updates the y-velocity of the GameObject.
|
void |
setX(float x)
Sets the center x-position of the GameObject.
|
void |
setY(float y)
Sets the bottom y-position of the GameObject.
|
abstract void |
update(float deltaTime)
Updates the GameObject's game logic.
|
void |
updateCollider()
Snaps the GameObject's collider to the GameObject's position
|
void |
updatePosition(float deltaTime)
Updates the position of the GameObject according to its velocity and acceleration.
|
public GameObject()
public GameObject(float x, float y, float width, float height)
public abstract void update(float deltaTime)
public void updatePosition(float deltaTime)
public void updateCollider()
public abstract boolean canTarget()
public Vector2 getPosition()
public void setPosition(float x, float y)
public float getX()
public void setX(float x)
public float getY()
public void setY(float y)
public Vector2 getPreviousPosition()
public Vector2 getVelocity()
public void setVelocity(float x, float y)
public void setVelocityX(float x)
public void setVelocityY(float y)
public Vector2 getAcceleration()
public void setAcceleration(float x, float y)
public void moveTo(float x, float y, float time)
public boolean isAbove(GameObject gameObject)
public <T extends Collider> T getCollider()
public void setCollider(Collider c)
public com.esotericsoftware.spine.Skeleton getSkeleton()
public void setSkeleton(com.esotericsoftware.spine.Skeleton skeleton)
public Cell getTerrainCell()
public void setTerrainCell(int row, int col)
public float getStateTime()
public void setStateTime(float stateTime)
public int getObjectId()
public void setObjectId(int objectId)