Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PolygonArea

Polygon collision area for detecting collisions for actors, or independently

Hierarchy

  • PolygonArea

Implements

Index

Constructors

constructor

Properties

Private _axes

_axes: Vector[] = []

Private _sides

_sides: Line[] = []

Private _transformedPoints

_transformedPoints: Vector[] = []

body

body: Body

points

points: Vector[]

pos

pos: Vector

Methods

Private _calculateTransformation

  • _calculateTransformation(): void
  • Calculates the underlying transformation from the body relative space to world space

    Returns void

collide

contains

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

    Parameters

    Returns boolean

debugDraw

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

    • ctx: CanvasRenderingContext2D
    • Default value color: Color = Color.Red.clone()

    Returns void

getAxes

  • Get the axis associated with the edge

    Returns Vector[]

getBounds

getCenter

  • Get the center of the collision area in world coordinates

    Returns Vector

getFurthestPoint

getMomentOfInertia

  • getMomentOfInertia(): number

getSides

  • getSides(): Line[]
  • Gets the sides of the polygon in world space

    Returns Line[]

getTransformedPoints

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

    Returns Vector[]

project

rayCast

  • 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
    • Default value max: number = Infinity

    Returns Vector

recalc

  • recalc(): void

testSeparatingAxisTheorem