Class PolygonHitbox
java.lang.Object
nl.saxion.gameapp.gameobject.hitbox.Hitbox
nl.saxion.gameapp.gameobject.hitbox.PolygonHitbox
Represents a polygon hitbox defined relative to the parent GameObject's size.
Vertices are stored as percentages of the parent width and height (0.0–1.0), allowing automatic scaling when the GameObject resizes. Supports arbitrary convex polygons and rotation.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPolygonHitbox(GameObject parent, float[] relVertices) Creates a new polygon hitbox relative to the parent GameObject. -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.math.PolygonReturns the polygon in absolute world coordinates, taking into account the parent GameObject's position and size.com.badlogic.gdx.math.Polygonfloat[]booleanChecks if this hitbox overlaps another hitbox.voidsetRotation(float degrees) Sets the rotation of the polygon hitbox.
-
Field Details
-
CIRCLE_NUM_SEGMENTS
public static final int CIRCLE_NUM_SEGMENTS- See Also:
-
-
Constructor Details
-
PolygonHitbox
Creates a new polygon hitbox relative to the parent GameObject.- Parameters:
parent- the GameObject this hitbox belongs torelVertices- array of vertices (x1,y1,x2,y2,...) in 0–1 percentages
-
-
Method Details
-
setRotation
public void setRotation(float degrees) Sets the rotation of the polygon hitbox.- Parameters:
degrees- rotation in degrees
-
getAbsolutePolygon
public com.badlogic.gdx.math.Polygon getAbsolutePolygon()Returns the polygon in absolute world coordinates, taking into account the parent GameObject's position and size.- Returns:
- polygon in world coordinates
-
overlaps
Checks if this hitbox overlaps another hitbox.Supports polygon-polygon, polygon-rectangle, and polygon-circle collisions.
-
getPolygon
public com.badlogic.gdx.math.Polygon getPolygon() -
getRelVertices
public float[] getRelVertices()
-