Skip to main content

PolygonCollider

Polygon collider for detecting collisions

Hierarchy

Index

Constructors

constructor

Properties

publiccomposite

composite: CompositeCollider = null

Composite collider if any this collider is attached to

WARNING do not tamper with this property

publicevents

events: EventEmitter<any> = ...

publicreadonlyid

id: Id<collider> = ...

publicoffset

offset: Vector

Pixel offset relative to a collider's body transform position.

publicowner

owner: Entity<any>

Accessors

publicaxes

  • Get the axis associated with the convex polygon


    Returns Vector[]

publicbounds

  • Get the axis aligned bounding box for the polygon collider in world coordinates


    Returns BoundingBox

publiccenter

  • Get the center of the collider in world coordinates


    Returns Vector

publiclocalBounds

  • Get the axis aligned bounding box for the polygon collider in local coordinates


    Returns BoundingBox

publicnormals

  • get normals(): readonly Vector[]

publicpoints

  • Points in the polygon in order around the perimeter in local coordinates. These are relative from the body transform position. Excalibur stores these in counter-clockwise order


    Returns Vector[]

  • Points in the polygon in order around the perimeter in local coordinates. These are relative from the body transform position. Excalibur stores these in counter-clockwise order


    Parameters

    Returns void

publictransform

publicworldPos

  • Returns the world position of the collider, which is the current body transform plus any defined offset


    Returns Vector

Methods

public_isCounterClockwiseWinding

  • _isCounterClockwiseWinding(points: Vector[]): boolean
  • Parameters

    Returns boolean

publicclone

  • Returns a clone of this ConvexPolygon, not associated with any collider


    Returns PolygonCollider

publiccollide

  • Returns a collision contact if the 2 colliders collide, otherwise collide will return null.


    Parameters

    Returns CollisionContact[]

publiccontains

  • contains(point: Vector): boolean
  • Tests if a point is contained in this collider in world space


    Parameters

    Returns boolean

publicdebug

  • Parameters

    Returns void

publicfindLocalSide

  • Given a direction vector find the local space side that is most in that direction


    Parameters

    Returns LineSegment

publicfindSide

  • Given a direction vector find the world space side that is most in that direction


    Parameters

    Returns LineSegment

publicflagDirty

  • flagDirty(): void
  • Returns void

publicgetClosestFace

publicgetClosestLineBetween

  • Returns the closest line between the surfaces this collider and another


    Parameters

    Returns LineSegment

publicgetFurthestLocalPoint

  • Find the local point on the collider furthest in the direction specified


    Parameters

    Returns Vector

publicgetFurthestPoint

  • Find the point on the collider furthest in the direction specified


    Parameters

    Returns Vector

publicgetInertia

  • getInertia(mass: number): number

publicgetLocalSides

  • Returns the local coordinate space sides


    Returns LineSegment[]

publicgetSides

  • Gets the sides of the polygon in world space


    Returns LineSegment[]

publicgetTransformedPoints

  • getTransformedPoints(): Vector[]
  • Gets the points that make up the polygon in world space, from actor relative space (if specified)


    Returns Vector[]

publicisConvex

  • isConvex(): boolean
  • Returns if the polygon collider is convex, Excalibur does not handle non-convex collision shapes. Call Polygon.triangulate to generate a CompositeCollider from this non-convex shape


    Returns boolean

publicproject

  • Project the edges of the polygon along a specified axis


    Parameters

    Returns Projection

publicrayCast

  • Casts a ray into the polygon and returns a vector representing the point of contact (in world space) or null if no collision.


    Parameters

    • ray: Ray
    • max: number = Infinity

    Returns RayCastHit

publictessellate

publictouching

  • Returns a boolean indicating whether this body collided with or was in stationary contact with the body of the other Collider


    Parameters

    Returns boolean

publictriangulate

publicupdate

  • Updates the transform for the collision geometry

    Collision geometry (points/bounds) will not change until this is called.


    Parameters

    Returns void