public class CollisionPolygon extends Polygon implements CollisionArea, PositionChangeListener<CollisionPolygon>, SizeChangeListener<CollisionPolygon>
Polygon that allows for interpolation. Game
objects can use this class to move around the game world and retrieve the
appropriate rendering coordinates during the render phase.| Modifier and Type | Field and Description |
|---|---|
protected Collisions |
collisions |
disposed, geometry, positionChangeListeners, sizeChangeListeners| Constructor and Description |
|---|
CollisionPolygon(float[] vertices) |
CollisionPolygon(int id,
Collisions collisions,
float[] vertices) |
CollisionPolygon(int id,
Collisions collisions,
org.mini2Dx.gdx.math.Vector2[] vectors) |
CollisionPolygon(int id,
float[] vertices) |
CollisionPolygon(int id,
org.mini2Dx.gdx.math.Vector2[] vectors) |
CollisionPolygon(org.mini2Dx.gdx.math.Vector2[] vectors) |
| Modifier and Type | Method and Description |
|---|---|
<T extends Positionable> |
addPostionChangeListener(PositionChangeListener<T> listener)
Adds a
Positionable to be notified of coordinate
changes |
<T extends Sizeable> |
addSizeChangeListener(SizeChangeListener<T> listener)
Adds a
SizeChangeListener to be notified of size changes |
void |
clearPositionChangeListeners()
Removes all listeners
|
void |
clearSizeChangeListeners()
Removes all listeners
|
void |
dispose()
|
boolean |
equals(java.lang.Object o) |
void |
forceTo(float[] vertices) |
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
|
void |
forceTo(float x,
float y,
float width,
float height)
Sets the current x, y, width and height and force updates the
rendering state 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
|
int |
getId()
Returns the unique id of this object
|
float |
getRawRenderHeight()
Returns the raw float value used for the render height coordinate
|
float |
getRawRenderWidth()
Returns the raw float value used for the render width coordinate
|
float |
getRawRenderX()
Returns the raw float value used for the render x coordinate
|
float |
getRawRenderY()
Returns the raw float value used for the render y coordinate
|
RenderCoordMode |
getRenderCoordMode()
Returns the mode used for calculating render coordinates
|
int |
getRenderHeight()
Returns the render height of this object using the set
RenderCoordMode |
int |
getRenderWidth()
Returns the render width of this object using the set
RenderCoordMode |
int |
getRenderX()
Returns the render x coordinate of this object using the set
RenderCoordMode |
int |
getRenderX(int index) |
int |
getRenderY()
Returns the render y coordinate of this object using the set
RenderCoordMode |
int |
getRenderY(int index) |
int |
hashCode() |
protected void |
init(int id,
float[] vertices) |
protected void |
init(int id,
org.mini2Dx.gdx.math.Vector2[] vectors) |
void |
interpolate(float alpha)
Called during interpolate phase each interpolate()
|
void |
notifyPositionChangeListeners()
Notifies all listeners of the current position.
|
void |
notifySizeChangeListeners()
Notifies all listeners when the size changes.
|
void |
positionChanged(CollisionPolygon moved) |
void |
preUpdate()
Called at the start of each update() before any changes are made to this object
|
protected void |
release() |
<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 |
setRenderCoordMode(RenderCoordMode mode)
Sets the mode used for calculating render coordinates
|
CollisionArea |
setTo(float x,
float y,
float width,
float height)
Sets the current x, y, width and height
|
void |
sizeChanged(CollisionPolygon changed) |
java.lang.String |
toString() |
addPoint, addPoint, contains, contains, contains, contains, copy, draw, edgeIterator, fill, getCenterX, getCenterY, getDistanceTo, getHeight, getMaxX, getMaxY, getMinX, getMinY, getNumberOfSides, getPolygon, getRotation, getTriangles, getVertices, getWidth, getX, getX, getY, getY, intersects, intersects, intersects, intersects, intersects, intersects, intersectsIgnoringEdges, intersectsIgnoringEdges, intersectsIgnoringEdges, intersectsLineSegment, intersectsLineSegment, isCircle, isEquilateral, isEquilateral, isRectangle, isSameAs, lerp, lerp, lerp, removePoint, removePoint, rotate, rotateAround, scale, set, setCenter, setCenterX, setCenterY, setRadius, setRotation, setRotationAround, setVertices, setVertices, setX, setXY, setY, sign, translate, triangleContainsadd, clearPositionListeners, clearPositionListeners, clearSizeListeners, clearSizeListeners, getDistanceTo, moveTowards, moveTowards, notifyPositionListeners, notifyPositionListeners, notifySizeListeners, notifySizeListeners, removePositionListener, removePositionListener, removeSizeListener, removeSizeListener, setDisposed, setRotationAround, subtractclone, finalize, getClass, notify, notifyAll, wait, wait, waitcontains, contains, contains, getCenterX, getCenterY, getHeight, getMaxX, getMaxY, getMinX, getMinY, getNumberOfSides, getPolygon, getWidth, intersects, intersects, intersectsIgnoringEdges, intersectsLineSegment, intersectsLineSegment, isCircle, scale, setCenter, setCenterX, setCenterY, setRadiusgetDistanceTo, getDistanceTo, getX, getY, moveTowards, moveTowards, setX, setXY, setYprotected Collisions collisions
public CollisionPolygon(float[] vertices)
public CollisionPolygon(org.mini2Dx.gdx.math.Vector2[] vectors)
public CollisionPolygon(int id,
float[] vertices)
public CollisionPolygon(int id,
org.mini2Dx.gdx.math.Vector2[] vectors)
public CollisionPolygon(int id,
Collisions collisions,
float[] vertices)
public CollisionPolygon(int id,
Collisions collisions,
org.mini2Dx.gdx.math.Vector2[] vectors)
protected void init(int id,
float[] vertices)
protected void init(int id,
org.mini2Dx.gdx.math.Vector2[] vectors)
protected void release()
public void dispose()
Shapedispose in interface CollisionObjectdispose in interface org.mini2Dx.gdx.utils.Disposabledispose in class Polygonpublic void preUpdate()
CollisionObjectpreUpdate in interface CollisionObjectpreUpdate in interface Interpolatablepublic void interpolate(float alpha)
CollisionObjectinterpolate in interface CollisionObjectinterpolate in interface Interpolatablealpha - The alpha value between 0.0 and 1.0public void forceTo(float x,
float y)
CollisionObjectforceTo in interface CollisionObjectx - The x coordinate to sety - The y coordinate to setpublic CollisionArea setTo(float x, float y, float width, float height)
CollisionAreasetTo in interface CollisionAreax - The x coordinate to sety - The y coordinate to setwidth - The width to setheight - The height to setpublic void forceTo(float x,
float y,
float width,
float height)
CollisionAreaforceTo in interface CollisionAreax - The x coordinate to sety - The y coordinate to setwidth - The width to setheight - The height to setpublic void forceToWidth(float width)
CollisionAreaforceToWidth in interface CollisionAreawidth - The width to setpublic void forceToHeight(float height)
CollisionAreaforceToHeight in interface CollisionAreaheight - The height to setpublic void forceTo(float[] vertices)
public int getId()
CollisionObjectgetId in interface CollisionObjectpublic int getRenderX()
CollisionObjectRenderCoordModegetRenderX in interface CollisionObjectpublic int getRenderY()
CollisionObjectRenderCoordModegetRenderY in interface CollisionObjectpublic float getRawRenderX()
CollisionObjectgetRawRenderX in interface CollisionObjectpublic float getRawRenderY()
CollisionObjectgetRawRenderY in interface CollisionObjectpublic int getRenderWidth()
CollisionAreaRenderCoordModegetRenderWidth in interface CollisionAreapublic int getRenderHeight()
CollisionAreaRenderCoordModegetRenderHeight in interface CollisionAreapublic float getRawRenderWidth()
CollisionAreagetRawRenderWidth in interface CollisionAreapublic float getRawRenderHeight()
CollisionAreagetRawRenderHeight in interface CollisionAreapublic int getRenderX(int index)
public int getRenderY(int index)
public void positionChanged(CollisionPolygon moved)
positionChanged in interface PositionChangeListener<CollisionPolygon>public void sizeChanged(CollisionPolygon changed)
sizeChanged in interface SizeChangeListener<CollisionPolygon>public <T extends Positionable> void addPostionChangeListener(PositionChangeListener<T> listener)
PositionablePositionable to be notified of coordinate
changesaddPostionChangeListener in interface PositionableaddPostionChangeListener in class Shapelistener - 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 PositionableremovePositionChangeListener in class Shapelistener - The PositionChangeListener to removePositionable.removePositionChangeListener(PositionChangeListener)public <T extends Sizeable> void addSizeChangeListener(SizeChangeListener<T> listener)
SizeableSizeChangeListener to be notified of size changesaddSizeChangeListener in interface SizeableaddSizeChangeListener in class Shapelistener - The SizeChangeListener to addpublic <T extends Sizeable> void removeSizeChangeListener(SizeChangeListener<T> listener)
SizeableSizeChangeListener to stop it being notified of size
changesremoveSizeChangeListener in interface SizeableremoveSizeChangeListener in class Shapelistener - The SizeChangeListener to removepublic void notifyPositionChangeListeners()
PositionablenotifyPositionChangeListeners in interface PositionablenotifyPositionChangeListeners in class Shapepublic void clearPositionChangeListeners()
PositionableclearPositionChangeListeners in interface PositionableclearPositionChangeListeners in class Shapepublic void notifySizeChangeListeners()
SizeablenotifySizeChangeListeners in interface SizeablenotifySizeChangeListeners in class Shapepublic void clearSizeChangeListeners()
SizeableclearSizeChangeListeners in interface SizeableclearSizeChangeListeners in class Shapepublic RenderCoordMode getRenderCoordMode()
CollisionObjectgetRenderCoordMode in interface CollisionObjectRenderCoordMode.GLOBAL_DEFAULTpublic void setRenderCoordMode(RenderCoordMode mode)
CollisionObjectsetRenderCoordMode in interface CollisionObjectmode - The RenderCoordMode value