Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BoundingBox

Axis Aligned collision primitive for Excalibur.

Hierarchy

  • BoundingBox

Implements

Index

Constructors

constructor

  • new BoundingBox(left?: number, top?: number, right?: number, bottom?: number): BoundingBox
  • Parameters

    • Default value left: number = 0

      x coordinate of the left edge

    • Default value top: number = 0

      y coordinate of the top edge

    • Default value right: number = 0

      x coordinate of the right edge

    • Default value bottom: number = 0

      y coordinate of the bottom edge

    Returns BoundingBox

Properties

bottom

bottom: number

y coordinate of the bottom edge

left

left: number

x coordinate of the left edge

right

right: number

x coordinate of the right edge

top

top: number

y coordinate of the top edge

Methods

collides

  • Test wether this bounding box collides with another returning, the intersection vector that can be used to resolve the collision. If there is no collision null is returned.

    Parameters

    Returns Vector

combine

  • Combines this bounding box and another together returning a new bounding box

    Parameters

    Returns BoundingBox

contains

  • Tests whether a point is contained within the bounding box

    Parameters

    Returns boolean

  • Tests whether another bounding box is totally contained in this one

    Parameters

    Returns boolean

debugDraw

  • debugDraw(ctx: CanvasRenderingContext2D, color?: Color): void
  • Parameters

    • ctx: CanvasRenderingContext2D
    • Default value color: Color = Color.Yellow

    Returns void

getHeight

  • getHeight(): number
  • Returns the calculated height of the bounding box

    Returns number

getPerimeter

  • getPerimeter(): number
  • Returns the perimeter of the bounding box

    Returns number

getPoints

  • Returns Vector[]

getWidth

  • getWidth(): number
  • Returns the calculated width of the bounding box

    Returns number

rayCast

  • rayCast(ray: Ray, farClipDistance?: number): boolean
  • Determines whether a ray intersects with a bounding box

    Parameters

    • ray: Ray
    • Default value farClipDistance: number = Infinity

    Returns boolean

rotate

  • Rotates a bounding box by and angle and around a point, if no point is specified (0, 0) is used by default

    Parameters

    • angle: number
    • Default value point: Vector = ex.Vector.Zero.clone()

    Returns BoundingBox

toPolygon

  • Creates a Polygon collision area from the points of the bounding box

    Parameters

    Returns PolygonArea

Static fromPoints

  • Parameters

    Returns BoundingBox