Class CircleHitbox
java.lang.Object
nl.saxion.gameapp.gameobject.hitbox.Hitbox
nl.saxion.gameapp.gameobject.hitbox.CircleHitbox
Represents a circular hitbox defined relative to the size of its parent
GameObject.
The center is defined as a percentage of the parent width/height, and the radius is defined as a percentage of the smaller of the parent's width and height. This ensures proper scaling when the object is resized.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCircleHitbox(GameObject parent, float relCenterX, float relCenterY, float relRadius) Creates a new circular hitbox relative to the parent GameObject. -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.math.CircleReturns the circle in absolute world coordinates, calculated from the parent GameObject's position and size.floatfloatfloatbooleanChecks if this hitbox overlaps another hitbox.
-
Constructor Details
-
CircleHitbox
Creates a new circular hitbox relative to the parent GameObject.- Parameters:
parent- the GameObject this hitbox belongs torelCenterX- x-coordinate of the center as percentage of parent widthrelCenterY- y-coordinate of the center as percentage of parent heightrelRadius- radius as percentage of min(parent width, parent height)
-
-
Method Details
-
getAbsoluteCircle
public com.badlogic.gdx.math.Circle getAbsoluteCircle()Returns the circle in absolute world coordinates, calculated from the parent GameObject's position and size.- Returns:
- the circle in world coordinates
-
overlaps
Checks if this hitbox overlaps another hitbox.Supports collisions with circles, rectangles, and polygons.
-
getRelCenterX
public float getRelCenterX() -
getRelCenterY
public float getRelCenterY() -
getRelRadius
public float getRelRadius()
-