public class CollisionPoint extends Point implements Positionable
Point 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 |
|---|
CollisionPoint() |
CollisionPoint(float x,
float y) |
CollisionPoint(int id) |
CollisionPoint(int id,
float x,
float y) |
CollisionPoint(int id,
Point point) |
CollisionPoint(Point point) |
| Modifier and Type | Method and Description |
|---|---|
com.badlogic.gdx.math.Vector2 |
add(float x,
float y) |
<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 position to match
|
float |
getDistanceTo(Positionable positionable)
Returns this distance between this object's x,y coordinates and the
provided
Positionable's xy coordinates |
int |
getId()
Returns the unique id of this object
|
int |
getRenderX()
Returns the render x coordinate of this object
|
int |
getRenderY()
Returns the render y coordinate of this object
|
void |
interpolate(GameContainer gc,
float alpha)
Interpolate between the previous and current state
|
void |
moveTowards(float x,
float y,
float speed)
Moves this
Positionable towards a coordinate |
void |
moveTowards(Positionable positionable,
float speed)
Moves this
Positionable towards another Positionable |
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 |
com.badlogic.gdx.math.Vector2 |
set(float x,
float y) |
void |
setX(float x)
Sets the x coordinate of this object
|
void |
setY(float y)
Sets the y coordinate of this object
|
com.badlogic.gdx.math.Vector2 |
sub(float x,
float y) |
void |
update(GameContainer gc,
float delta)
Updates the game screen
|
add, copy, equals, equals, equals, getDistanceTo, getDistanceTo, getX, getY, isOnLineBetween, rotateAround, rotateAround, set, subangle, angle, angleRad, angleRad, clamp, cpy, crs, crs, dot, dot, dot, dst, dst, dst, dst2, dst2, dst2, epsilonEquals, epsilonEquals, equals, fromString, hashCode, hasOppositeDirection, hasSameDirection, interpolate, isCollinear, isCollinear, isCollinearOpposite, isCollinearOpposite, isOnLine, isOnLine, isPerpendicular, isPerpendicular, isUnit, isUnit, isZero, isZero, len, len, len2, len2, lerp, limit, limit2, mul, mulAdd, mulAdd, nor, rotate, rotate90, rotateRad, scl, scl, scl, setAngle, setAngleRad, setLength, setLength2, setToRandomDirection, setZero, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetDistanceTo, getDistanceTo, getX, getYpublic CollisionPoint()
public CollisionPoint(int id)
public CollisionPoint(float x,
float y)
public CollisionPoint(int id,
float x,
float y)
public CollisionPoint(Point point)
public CollisionPoint(int id,
Point point)
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 float getDistanceTo(Positionable positionable)
PositionablePositionable's xy coordinatesgetDistanceTo in interface Positionablepositionable - The Positionable to retrieve the distance frompublic <T extends Positionable> void addPostionChangeListener(PositionChangeListener<T> listener)
PositionablePositionChangeListener to be notified of coordinate
changesaddPostionChangeListener in interface Positionablelistener - The PositionChangeListener to addpublic <T extends Positionable> void removePositionChangeListener(PositionChangeListener<T> listener)
PositionablePositionChangeListener to stop it being notified of
coordinate changesremovePositionChangeListener in interface Positionablelistener - The PositionChangeListener to removepublic void moveTowards(float x,
float y,
float speed)
PositionablePositionable towards a coordinatemoveTowards in interface Positionablex - The target x coordinatey - The target y coordinatespeed - The amount to move bypublic void moveTowards(Positionable positionable, float speed)
PositionablePositionable towards another PositionablemoveTowards in interface Positionablepositionable - The target Positionablespeed - The amount to move bypublic void forceTo(float x,
float y)
x - The x coordinate to sety - The y coordinate to setpublic void setX(float x)
PositionablesetX in interface PositionablesetX in class Pointx - The x coordinatepublic void setY(float y)
PositionablesetY in interface PositionablesetY in class Pointy - The y coordinatepublic com.badlogic.gdx.math.Vector2 set(float x,
float y)
set in class com.badlogic.gdx.math.Vector2public com.badlogic.gdx.math.Vector2 add(float x,
float y)
add in class com.badlogic.gdx.math.Vector2public com.badlogic.gdx.math.Vector2 sub(float x,
float y)
sub in class com.badlogic.gdx.math.Vector2public int getRenderX()
PositionablegetRenderX in interface Positionablepublic int getRenderY()
PositionablegetRenderY in interface Positionablepublic int getId()
PositionablegetId in interface Positionable