Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: HitBox

[16:7] extends: FxObj

Wraps FXGL's HitBox (com.almasb.fxgl.physics.HitBox), the named bounding-collision box attached to a BoundingBoxComponent. Carries a BoundingShape (box / circle / polygon), local-origin offset, and a transform-aware world bounds. Used by collision handlers, raycasts, and the SAT solver.

Methods

  • HitBox (string Name = "", object ShapeAjo = null)

    Creates a new HitBox. Pass the BoundingShape and an optional name. When name is omitted, FXGL auto-generates one from the shape hash.

    • @p Name is the hit-box name (use "" to auto-generate).
    • @p ShapeAjo is a BoundingShape AJO.
  • adopt (object Ajo)

    Wraps an existing HitBox AussomJavaObject.

  • getName ()

  • getShape ()

    Returns the BoundingShape AJO.

  • getBounds ()

    Returns the JavaFX Bounds AJO.

  • getMinX ()

  • getMinY ()

  • getMaxX ()

  • getMaxY ()

  • getWidth ()

  • getHeight ()

  • getMinXWorld ()

  • getMaxXWorld ()

  • getMinYWorld ()

  • getMaxYWorld ()

  • getCenterWorld ()

    Returns the world-coordinate center as a Point2D AJO.

  • centerLocal ()

    Returns the local-coordinate center as a Point2D AJO.

  • centerWorld (double X, double Y)

    Returns the world-coordinate center at the given world (x, y) — useful for projecting the local center onto a specific world position.

  • bindXY (object TransformComponentObj)

    Binds this hit box's world position to the given TransformComponent. Used internally by BoundingBoxComponent.addHitBox.

  • unbind ()

    Unbinds this hit box from any TransformComponent.

  • getFastMinX ()

    Returns the fast-path local min X (avoids the Shape's getBounds() call). Use in hot loops.

  • getFastMinY ()

    Fast-path local min Y.

  • getFastMaxX ()

    Fast-path local max X.

  • getFastMaxY ()

    Fast-path local max Y.

  • applyTransform (object AffineAjo)

    Applies an Affine transform AJO to this hit box and returns the transformed Bounds AJO. Used by collision queries that project the hit box through an Entity's transform.

  • toBox2DShape (object BBCObj, object UnitConverterAjo)

    Returns the Box2D Shape AJO derived from this hit box (used by the physics broker when assembling a Fixture). Falls back to a polygon shape for box / chain inputs.

    • @p BBCObj is the BoundingBoxComponent owning this hit box.
    • @p UnitConverterAjo is a PhysicsUnitConverter AJO (pixel <-> Box2D meter scale).