public class CollisionPolygon extends Polygon implements CollisionShape
Constructor and Description |
---|
CollisionPolygon(float[] vertices) |
CollisionPolygon(int id,
float[] vertices) |
CollisionPolygon(int id,
com.badlogic.gdx.math.Vector2[] vectors) |
CollisionPolygon(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 |
void |
addPoint(float x,
float y)
Adds an additional point to this
Polygon |
<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 |
draw(Graphics g)
Draws this shape using a
Graphics instance |
void |
fill(Graphics g)
Fills this shape using a
Graphics instance |
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
|
void |
removePoint(float x,
float y)
Removes a point from this
Polygon |
<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 |
rotate(float degrees)
Rotates this
Shape by a specified amount of degrees with its
first point as the origin |
void |
rotateAround(float centerX,
float centerY,
float degrees)
Rotates this
Shape by a specified amount of degrees around a
specified point |
void |
scale(float scale)
Scales the radius of this shape.
|
void |
set(float x,
float y)
Sets the x and y coordinate of this object
|
void |
setRadius(float radius)
Sets the radius of this shape.
|
void |
setRotation(float degrees)
Sets the rotation of this
Shape with its first point as the
origin |
void |
setRotationAround(float centerX,
float centerY,
float degrees)
Sets the rotation of this
Shape with a specified point as the
origin |
void |
setVertices(float[] vertices) |
void |
setVertices(com.badlogic.gdx.math.Vector2[] vertices) |
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, contains, contains, contains, contains, copy, edgeIterator, 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, set, sign, toString, translate, triangleContains
getDistanceTo
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, contains, intersects, intersects, intersectsLineSegment, intersectsLineSegment
getDistanceTo, getDistanceTo, getX, getY
public CollisionPolygon(float[] vertices)
public CollisionPolygon(com.badlogic.gdx.math.Vector2[] vectors)
public CollisionPolygon(int id, float[] vertices)
public CollisionPolygon(int id, com.badlogic.gdx.math.Vector2[] vectors)
public 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 void draw(Graphics g)
Shape
Graphics
instancepublic void fill(Graphics g)
Shape
Graphics
instancepublic int getId()
Positionable
getId
in interface Positionable
getId
in interface Sizeable
public 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 <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 addPoint(float x, float y)
Polygon
Polygon
public void removePoint(float x, float y)
Polygon
Polygon
removePoint
in class Polygon
x
- The x coordinatey
- The y coordinatepublic 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 add(float x, float y)
Shape
Shape
public void subtract(float x, float y)
Shape
Shape
public void setX(float x)
Shape
setX
in interface Positionable
setX
in class Polygon
x
- The x coordinatepublic void setY(float y)
Shape
setY
in interface Positionable
setY
in class Polygon
y
- The y coordinatepublic void set(float x, float y)
Shape
public void forceTo(float x, float y)
CollisionShape
forceTo
in interface CollisionShape
x
- The x coordinate to sety
- The y coordinate to setpublic void setRotation(float degrees)
Shape
Shape
with its first point as the
originsetRotation
in class Polygon
degrees
- The rotation in degreespublic void rotate(float degrees)
Shape
Shape
by a specified amount of degrees with its
first point as the originpublic void setRotationAround(float centerX, float centerY, float degrees)
Shape
Shape
with a specified point as the
originsetRotationAround
in class Polygon
centerX
- The origin/center x coordinatecenterY
- The origin/center y coordinatedegrees
- The rotation in degreespublic void rotateAround(float centerX, float centerY, float degrees)
Shape
Shape
by a specified amount of degrees around a
specified pointrotateAround
in class Polygon
centerX
- The origin/center x coordinatecenterY
- The origin/center y coordinatedegrees
- The rotation in degreespublic void setVertices(float[] vertices)
setVertices
in class Polygon
public void setVertices(com.badlogic.gdx.math.Vector2[] vertices)
setVertices
in class Polygon
public void setRadius(float radius)
Shape
public void scale(float scale)
Shape
public int getRenderX()
Positionable
getRenderX
in interface Positionable
public int getRenderY()
Positionable
getRenderY
in interface Positionable
public float getWidth()
Sizeable
public float getHeight()
Sizeable
public Shape getShape()
CollisionShape
Shape
instancegetShape
in interface CollisionShape