Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: BoundingBoxComponent

[15:7] extends: Component

Wraps FXGL's BoundingBoxComponent (com.almasb.fxgl.entity.components.BoundingBoxComponent), the component that holds an entity's HitBoxes and exposes width / height / centers used by Entity collision detection. Reachable through Entity.getBoundingBoxComponent().

Methods

  • BoundingBoxComponent ()

    Creates a new empty BoundingBoxComponent.

  • adopt (object Ajo)

    Wraps an existing BoundingBoxComponent AussomJavaObject.

  • addHitBox (object HitBoxObj)

    Adds a HitBox to the component.

  • removeHitBox (string Name)

    Removes a HitBox by name.

  • clearHitBoxes ()

    Clears every HitBox.

  • hitBoxesProperty ()

    Returns the HitBox list AJO.

  • getWidth ()

    Returns the total width of the bbox.

  • getHeight ()

    Returns the total height of the bbox.

  • getMinXLocal ()

    Returns the minimum X among all hit boxes (entity-local).

  • getMinYLocal ()

    Returns the minimum Y among all hit boxes (entity-local).

  • getMaxXWorld ()

    Returns the right-edge X in world coordinates.

  • getMaxYWorld ()

    Returns the bottom-edge Y in world coordinates.

  • getCenterLocal ()

    Returns the geometric center as a Point2D AJO.

  • getCenterWorld ()

    Returns the world-coords center as a Point2D AJO.

  • widthProperty ()

    Returns the width DoubleProperty.

  • heightProperty ()

    Returns the height DoubleProperty.

  • isCollidingWith (object Other)

    Returns whether this bbox is currently colliding with Other.

  • getMaxXLocal ()

    Returns the maximum X among all hit boxes (entity-local).

  • getMaxYLocal ()

    Returns the maximum Y among all hit boxes (entity-local).

  • getMinXWorld ()

    Returns the left-edge X in world coordinates.

  • getMinYWorld ()

    Returns the top-edge Y in world coordinates.

  • minXLocalProperty ()

    Returns the min-X-local ReadOnlyDoubleProperty for binding.

  • minYLocalProperty ()

    Returns the min-Y-local ReadOnlyDoubleProperty for binding.

  • minXWorldProperty ()

    Returns the min-X-world ReadOnlyDoubleProperty for binding.

  • minYWorldProperty ()

    Returns the min-Y-world ReadOnlyDoubleProperty for binding.

  • maxXWorldProperty ()

    Returns the max-X-world ReadOnlyDoubleProperty for binding.

  • maxYWorldProperty ()

    Returns the max-Y-world ReadOnlyDoubleProperty for binding.

  • getTransform ()

    Returns the underlying TransformComponent this bbox uses. The field is normally injected by the entity; the getter is mostly useful for inspection.

  • setTransform (object TransformObj)

    Replaces the TransformComponent driving this bbox. Pass a TransformComponent wrapper or raw AJO.

  • checkCollision (object Other, object ResultAjo)

    Runs the precise SAT collision check between this bbox and Other, writing intersection info into Result.

    • @p Other is a BoundingBoxComponent wrapper.
    • @p ResultAjo is a CollisionResult AJO to populate.
    • @r true on collision, false otherwise.
  • checkCollisionPAT (object Other, object ResultAjo)

    Polygon-against-translated-rect collision variant of checkCollision.

  • isWithin (double X, double Y, double Width, double Height)

    Returns true if the world bbox is fully contained within (X, Y, Width, Height).

  • isOutside (double X, double Y, double Width, double Height)

    Returns true if the world bbox is fully outside (X, Y, Width, Height).

  • range (double RangeX, double RangeY)

    Returns the world bbox extended by RangeX horizontally and RangeY vertically as a Rectangle2D AJO. Useful for collision range checks.

  • onAdded ()

    Lifecycle hook fired when the component is attached to an Entity. Aussom code rarely calls this directly; the engine triggers it automatically.

  • onRemoved ()

    Lifecycle hook fired when the component is detached.

  • write (object BundleObj)

    Persists this bbox's hit-box list into a Bundle.

    • @p BundleObj is a Bundle wrapper.
  • read (object BundleObj)

    Restores the hit-box list from a Bundle previously written via write.