public class StaticCollisionPolygon extends Polygon implements CollisionShape
Polygon implementation of CollisionShape that does not
need to be updated/interpolated. More lightweight than using a
CollisionPolygon for static collisions.| Constructor and Description |
|---|
StaticCollisionPolygon(float[] vertices) |
StaticCollisionPolygon(int id,
float[] vertices) |
StaticCollisionPolygon(int id,
com.badlogic.gdx.math.Vector2[] vectors) |
StaticCollisionPolygon(com.badlogic.gdx.math.Vector2[] vectors) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(float x,
float y)
Adds components to the position of this
Shape |
<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 |
boolean |
equals(java.lang.Object o) |
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
|
int |
hashCode() |
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 |
set(float x,
float y)
Sets the x and y coordinate of this object
|
void |
setCenter(float x,
float y)
Sets the center x,y coordinate of this object
|
void |
setCenterX(float x)
Sets the center x coordinate
|
void |
setCenterY(float y)
Sets the center y coordianate
|
void |
setX(float x)
Sets the x coordinate of this object
|
void |
setY(float y)
Sets the y coordinate of this object
|
void |
subtract(float x,
float y)
Subtracts components from the position of this
Shape |
void |
update(GameContainer gc,
float delta)
Updates the game screen
|
addPoint, addPoint, contains, contains, contains, contains, copy, draw, edgeIterator, fill, getCenterX, getCenterY, getDistanceTo, getMaxX, getMaxY, getMinX, getMinY, getNumberOfSides, getPolygon, getRotation, getTriangles, getVertices, getX, getX, getY, getY, intersects, intersects, intersects, intersects, intersects, intersects, intersectsLineSegment, intersectsLineSegment, isCircle, isEquilateral, isEquilateral, isRectangle, isSameAs, lerp, removePoint, removePoint, rotate, rotateAround, scale, set, setRadius, setRotation, setRotationAround, setVertices, setVertices, sign, toString, translate, triangleContainsgetDistanceToclone, finalize, getClass, notify, notifyAll, wait, wait, waitcontains, contains, intersects, intersects, intersectsLineSegment, intersectsLineSegmentgetDistanceTo, getDistanceTo, getX, getYgetCenterX, getCenterY, getMaxX, getMaxY, getMinX, getMinY, scale, setRadiuspublic StaticCollisionPolygon(float[] vertices)
public StaticCollisionPolygon(com.badlogic.gdx.math.Vector2[] vectors)
public StaticCollisionPolygon(int id,
float[] vertices)
public StaticCollisionPolygon(int id,
com.badlogic.gdx.math.Vector2[] vectors)
public int getId()
PositionablegetId in interface PositionablegetId in interface Sizeablepublic int getRenderX()
PositionablegetRenderX in interface Positionablepublic int getRenderY()
PositionablegetRenderY in interface Positionablepublic float getDistanceTo(Positionable positionable)
PositionablePositionable's xy coordinatesgetDistanceTo in interface Positionablepositionable - The Positionable to retrieve the distance frompublic 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 preUpdate()
CollisionShapepreUpdate in interface CollisionShapepublic 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 <T extends Sizeable> void addSizeChangeListener(SizeChangeListener<T> listener)
SizeableSizeChangeListener to be notified of size changesaddSizeChangeListener in interface Sizeablelistener - The SizeChangeListener to addpublic <T extends Sizeable> void removeSizeChangeListener(SizeChangeListener<T> listener)
SizeableSizeChangeListener to stop it being notified of size
changesremoveSizeChangeListener in interface Sizeablelistener - The SizeChangeListener to removepublic float getWidth()
Sizeablepublic float getHeight()
Sizeablepublic void forceTo(float x,
float y)
CollisionShapeforceTo in interface CollisionShapex - The x coordinate to sety - The y coordinate to setpublic void add(float x,
float y)
ShapeShapepublic void subtract(float x,
float y)
ShapeShapepublic void setX(float x)
ShapesetX in interface PositionablesetX in class Polygonx - The x coordinatepublic void setY(float y)
ShapesetY in interface PositionablesetY in class Polygony - The y coordinatepublic void set(float x,
float y)
Shapeset in interface CollisionShapeset in class Polygonx - The x coordinatey - The y coordinatepublic void setCenter(float x,
float y)
Shapepublic void setCenterX(float x)
ShapesetCenterX in interface SizeablesetCenterX in class Polygonx - The x coordinate of the shape's centerpublic void setCenterY(float y)
ShapesetCenterY in interface SizeablesetCenterY in class Polygony - The y coordinate of the shape's centerpublic Shape getShape()
CollisionShapeShape instancegetShape in interface CollisionShape