|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.brackeen.javagamebook.game.GameObject
A GameObject class is a base class for any type of object in a game that is represented by a PolygonGroup. For example, a GameObject can be a static object (like a crate), a moving object (like a projectile or a bad guy), or any other type of object (like a power-ups). GameObjects have three basic states: STATE_IDLE, STATE_ACTIVE, or STATE_DESTROYED.
Field Summary | |
static int |
STATE_ACTIVE
Represents a GameObject that is active. |
static int |
STATE_DESTROYED
Represents a GameObject that has been destroyed, and should no longer be updated or drawn. |
static int |
STATE_IDLE
Represents a GameObject that is idle. |
Constructor Summary | |
GameObject(PolygonGroup polygonGroup)
Creates a new GameObject represented by the specified PolygonGroup. |
Method Summary | |
void |
addListener(GameObjectEventListener l)
Adds a GameObjectEventListener to this object. |
PolygonGroupBounds |
getBounds()
Gets the bounds of this object's PolygonGroup. |
float |
getCeilHeight()
Gets the ceiling height set in the setCeilHeight method. |
float |
getFloorHeight()
Gets the floor height set in the setFloorHeight method. |
GameObjectEventListener |
getListener()
Gets the GameObjectEventListener for this object. |
Vector3D |
getLocation()
Shortcut to get the location of this GameObject from the Transform3D. |
java.lang.String |
getName()
Gets the name of this object's PolygonGroup. |
PolygonGroup |
getPolygonGroup()
Gets this object's PolygonGroup. |
java.util.List |
getSpawns()
Returns a list of "spawned" objects (projectiles, exploding parts, etc) or null if no objects were spawned. |
MovingTransform3D |
getTransform()
Gets this object's transform. |
float |
getX()
Shortcut to get the X location of this GameObject. |
float |
getY()
Shortcut to get the Y location of this GameObject. |
float |
getZ()
Shortcut to get the Z location of this GameObject. |
boolean |
isActive()
Returns true if this GameObject is active. |
boolean |
isDestroyed()
Returns true if this GameObject is destroyed. |
boolean |
isFlying()
Checks if this GameObject is currently flying. |
boolean |
isIdle()
Returns true if this GameObject is idle. |
boolean |
isJumping()
Checks if this GameObject's jumping flag is set. |
boolean |
isMakingNoise()
Returns true if this object is making a "noise". |
void |
makeNoise(long duration)
Signifies that this object is making a "noise" of the specified duration. |
void |
removeListener(GameObjectEventListener l)
Removes a GameObjectEventListener from this object. |
void |
sendTouchNotifications()
After this object has moved and collisions have been checked, this method is called to send any touch/release notifications. |
void |
setCeilHeight(float ceilHeight)
Method to record the height of the ceiling that this GameObject is under. |
void |
setFloorHeight(float floorHeight)
Method to record the height of the floor that this GameObject is on. |
void |
setFlying(boolean isFlying)
Sets whether this GameObject is currently flying. |
void |
setJumping(boolean b)
Sets this GameObject's jumping flag. |
void |
setState(int state)
Sets the state of this object. |
void |
update(GameObject player,
long elapsedTime)
If this GameObject is in the active state, this method updates it's PolygonGroup. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int STATE_IDLE
public static final int STATE_ACTIVE
public static final int STATE_DESTROYED
Constructor Detail |
public GameObject(PolygonGroup polygonGroup)
Method Detail |
public Vector3D getLocation()
public MovingTransform3D getTransform()
public PolygonGroup getPolygonGroup()
public java.lang.String getName()
public PolygonGroupBounds getBounds()
public float getX()
public float getY()
public float getZ()
public void setFloorHeight(float floorHeight)
public void setCeilHeight(float ceilHeight)
public float getFloorHeight()
public float getCeilHeight()
public void setState(int state)
public boolean isFlying()
public void setFlying(boolean isFlying)
public boolean isJumping()
public void setJumping(boolean b)
public boolean isIdle()
public boolean isActive()
public boolean isDestroyed()
public boolean isMakingNoise()
public void makeNoise(long duration)
public java.util.List getSpawns()
public void update(GameObject player, long elapsedTime)
public GameObjectEventListener getListener()
public void addListener(GameObjectEventListener l)
public void removeListener(GameObjectEventListener l)
public void sendTouchNotifications()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |