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, sub
angle, 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, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getDistanceTo, getDistanceTo, getX, getY
public 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)
Updatable
update
in interface Updatable
gc
- The GameContainer
of the gamedelta
- The time in seconds since the last updatepublic void interpolate(GameContainer gc, float alpha)
Updatable
interpolate
in interface Updatable
alpha
- The interpolation alpha valuepublic float getDistanceTo(Positionable positionable)
Positionable
Positionable
's xy coordinatesgetDistanceTo
in interface Positionable
positionable
- The Positionable
to retrieve the distance frompublic <T extends Positionable> void addPostionChangeListener(PositionChangeListener<T> listener)
Positionable
PositionChangeListener
to be notified of coordinate
changesaddPostionChangeListener
in interface Positionable
listener
- The PositionChangeListener
to addpublic <T extends Positionable> void removePositionChangeListener(PositionChangeListener<T> listener)
Positionable
PositionChangeListener
to stop it being notified of
coordinate changesremovePositionChangeListener
in interface Positionable
listener
- The PositionChangeListener
to removepublic void moveTowards(float x, float y, float speed)
Positionable
Positionable
towards a coordinatemoveTowards
in interface Positionable
x
- The target x coordinatey
- The target y coordinatespeed
- The amount to move bypublic void moveTowards(Positionable positionable, float speed)
Positionable
Positionable
towards another Positionable
moveTowards
in interface Positionable
positionable
- The target Positionable
speed
- 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)
Positionable
setX
in interface Positionable
setX
in class Point
x
- The x coordinatepublic void setY(float y)
Positionable
setY
in interface Positionable
setY
in class Point
y
- The y coordinatepublic com.badlogic.gdx.math.Vector2 set(float x, float y)
set
in class com.badlogic.gdx.math.Vector2
public com.badlogic.gdx.math.Vector2 add(float x, float y)
add
in class com.badlogic.gdx.math.Vector2
public com.badlogic.gdx.math.Vector2 sub(float x, float y)
sub
in class com.badlogic.gdx.math.Vector2
public int getRenderX()
Positionable
getRenderX
in interface Positionable
public int getRenderY()
Positionable
getRenderY
in interface Positionable
public int getId()
Positionable
getId
in interface Positionable