public class CollisionBox extends Rectangle implements Positionable
Rectangle that allows for interpolation. Game
objects can use this class to move around the game world and retrieve the
appropriate rendering coordinates after interpolating between the previous
and current position.| Constructor and Description |
|---|
CollisionBox() |
CollisionBox(float x,
float y,
float width,
float height) |
| Modifier and Type | Method and Description |
|---|---|
<T extends Positionable> |
addPostionChangeListener(PositionChangeListener<T> listener)
Adds a
PositionChangeListener to be notified of coordinate
changes |
void |
forceTo(float x,
float y)
Sets the current x and y coordinate to the specified x and y and force updates the
rendering bounds to match
|
void |
forceTo(float x,
float y,
float width,
float height)
Sets the current bounds to the specified bounds and force updates the
rendering bounds to match
|
void |
forceToHeight(float height)
Sets the current height to the specified height and force updates the
rendering bounds to match
|
void |
forceToWidth(float width)
Sets the current width to the specified width and force updates the
rendering bounds to match
|
float |
getDistanceTo(Positionable positionable)
Returns this distance between this object's x,y coordinates and the
provided
Positionable's xy coordinates |
float |
getRenderHeight() |
float |
getRenderRotation() |
float |
getRenderWidth() |
float |
getRenderX() |
float |
getRenderY() |
void |
interpolate(GameContainer gc,
float alpha)
Interpolate between the previous and current state
|
void |
preUpdate()
This method needs to be called at the start of each frame
before any changes are made to this object
|
<T extends Positionable> |
removePositionChangeListener(PositionChangeListener<T> listener)
Removes a
PositionChangeListener to stop it being notified of
coordinate changes |
void |
rotateAround(Point center,
float degrees)
Rotates the shape around a center point by the specified degrees adding
to its existing rotation
|
Rectangle |
set(float x,
float y,
float width,
float height) |
void |
set(Rectangle rectangle) |
com.badlogic.gdx.math.Rectangle |
set(com.badlogic.gdx.math.Rectangle rectangle) |
Rectangle |
setHeight(float height) |
Rectangle |
setPosition(float x,
float y) |
Rectangle |
setPosition(com.badlogic.gdx.math.Vector2 position) |
void |
setRotationAround(Point center,
float degrees)
Sets the current rotation of the shape around a center point
|
Rectangle |
setSize(float sizeXY) |
Rectangle |
setSize(float width,
float height) |
Rectangle |
setWidth(float width) |
Rectangle |
setX(float x) |
Rectangle |
setY(float y) |
void |
update(GameContainer gc,
float delta)
Updates the game screen
|
contains, contains, contains, contains, contains, debug, draw, getCenterX, getCenterY, getDistanceTo, getDistanceTo, getMaxX, getMaxY, getMinX, getMinY, getNumberOfSides, getRotation, intersection, intersects, intersects, intersects, intersects, lerp, overlaps, rotate, setRotation, toStringarea, equals, fitInside, fitOutside, getAspectRatio, getCenter, getHeight, getPosition, getSize, getWidth, getX, getY, hashCode, merge, merge, merge, merge, perimeter, setCenter, setCenterclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetX, getYgetHeight, getWidthpublic CollisionBox()
public CollisionBox(float x,
float y,
float width,
float height)
public void preUpdate()
public void update(GameContainer gc, float delta)
Updatableupdate in interface Updatablegc - The GameContainer of the gamedelta - The time in seconds since the last updatepublic void interpolate(GameContainer gc, float alpha)
Updatableinterpolate in interface Updatablealpha - The interpolation alpha valuepublic <T extends Positionable> void addPostionChangeListener(PositionChangeListener<T> listener)
PositionablePositionChangeListener to be notified of coordinate
changesaddPostionChangeListener in interface Positionablelistener - The PositionChangeListener to addPositionable.addPostionChangeListener(PositionChangeListener)public <T extends Positionable> void removePositionChangeListener(PositionChangeListener<T> listener)
PositionablePositionChangeListener to stop it being notified of
coordinate changesremovePositionChangeListener in interface Positionablelistener - The PositionChangeListener to removePositionable.removePositionChangeListener(PositionChangeListener)public void setRotationAround(Point center, float degrees)
ParallelogramsetRotationAround in interface ParallelogramsetRotationAround in class Rectanglecenter - The center point to rotate arounddegrees - The rotation angle in degreesParallelogram.setRotationAround(Point, float)public void rotateAround(Point center, float degrees)
ParallelogramrotateAround in interface ParallelogramrotateAround in class Rectangledegrees - The rotation in degreesParallelogram.rotateAround(Point, float)public float getDistanceTo(Positionable positionable)
PositionablePositionable's xy coordinatesgetDistanceTo in interface Positionablepositionable - The Positionable to retrieve the distance frompublic void forceTo(float x,
float y)
x - The x coordinate to sety - The y coordinate to setpublic void forceTo(float x,
float y,
float width,
float height)
x - The x coordinate to sety - The y coordinate to setwidth - The width to setheight - The height to setpublic void forceToWidth(float width)
width - The width to setpublic void forceToHeight(float height)
height - The height to setpublic Rectangle set(float x, float y, float width, float height)
public com.badlogic.gdx.math.Rectangle set(com.badlogic.gdx.math.Rectangle rectangle)
public Rectangle setPosition(float x, float y)
setPosition in class Rectanglepublic Rectangle setPosition(com.badlogic.gdx.math.Vector2 position)
setPosition in class Rectanglepublic float getRenderX()
public float getRenderY()
public float getRenderWidth()
public float getRenderHeight()
public float getRenderRotation()