public class StaticCollisionCircle extends Circle implements CollisionShape
Circle
implementation of CollisionShape
that does not
need to be updated/interpolated. More lightweight than using a
CollisionCircle
for static collisions.Constructor and Description |
---|
StaticCollisionCircle(float radius) |
StaticCollisionCircle(float centerX,
float centerY,
float radius) |
StaticCollisionCircle(int id,
float radius) |
StaticCollisionCircle(int id,
float centerX,
float centerY,
float radius) |
Modifier and Type | Method and Description |
---|---|
<T extends Positionable> |
addPostionChangeListener(PositionChangeListener<T> listener)
Adds a
PositionChangeListener to be notified of coordinate
changes |
<T extends Sizeable> |
addSizeChangeListener(SizeChangeListener<T> listener)
Adds a
SizeChangeListener to be notified of size 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 |
float |
getHeight()
Returns the height of this object
|
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
|
Shape |
getShape()
Returns the underlying
Shape instance |
float |
getWidth()
Returns the width 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 |
<T extends Sizeable> |
removeSizeChangeListener(SizeChangeListener<T> listener)
Removes a
SizeChangeListener to stop it being notified of size
changes |
void |
update(GameContainer gc,
float delta)
Updates the game screen
|
contains, contains, contains, contains, contains, contains, copy, draw, edgeIterator, fill, getBoundingBox, getCenterX, getCenterY, getDistanceFromCenter, getDistanceFromCenter, getDistanceTo, getDistanceTo, getMaxX, getMaxY, getMinX, getMinY, getNumberOfSides, getPolygon, getRadius, getRotation, getX, getY, intersects, intersects, intersects, intersectsLineSegment, intersectsLineSegment, isCircle, lerp, rotate, rotateAround, scale, set, set, setRadius, setRotation, setRotationAround, setX, setY, translate
add, getDistanceTo, intersects, subtract
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
contains, contains, intersects, intersects, intersectsLineSegment, intersectsLineSegment
getDistanceTo, getDistanceTo, getX, getY, setX, setY
public StaticCollisionCircle(float radius)
public StaticCollisionCircle(int id, float radius)
public StaticCollisionCircle(float centerX, float centerY, float radius)
public StaticCollisionCircle(int id, float centerX, float centerY, float radius)
public int getId()
Positionable
getId
in interface Positionable
getId
in interface Sizeable
public int getRenderX()
Positionable
getRenderX
in interface Positionable
public int getRenderY()
Positionable
getRenderY
in interface Positionable
public float getDistanceTo(Positionable positionable)
Positionable
Positionable
's xy coordinatesgetDistanceTo
in interface Positionable
positionable
- The Positionable
to retrieve the distance frompublic 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 preUpdate()
CollisionShape
preUpdate
in interface CollisionShape
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 <T extends Positionable> void addPostionChangeListener(PositionChangeListener<T> listener)
Positionable
PositionChangeListener
to be notified of coordinate
changesaddPostionChangeListener
in interface Positionable
listener
- The PositionChangeListener
to addPositionable.addPostionChangeListener(PositionChangeListener)
public <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 removePositionable.removePositionChangeListener(PositionChangeListener)
public <T extends Sizeable> void addSizeChangeListener(SizeChangeListener<T> listener)
Sizeable
SizeChangeListener
to be notified of size changesaddSizeChangeListener
in interface Sizeable
listener
- The SizeChangeListener
to addpublic <T extends Sizeable> void removeSizeChangeListener(SizeChangeListener<T> listener)
Sizeable
SizeChangeListener
to stop it being notified of size
changesremoveSizeChangeListener
in interface Sizeable
listener
- The SizeChangeListener
to removepublic void forceTo(float x, float y)
CollisionShape
forceTo
in interface CollisionShape
x
- The x coordinate to sety
- The y coordinate to setpublic float getWidth()
Sizeable
public float getHeight()
Sizeable
public Shape getShape()
CollisionShape
Shape
instancegetShape
in interface CollisionShape