Home Reference Source
protected class | source

Body

Direct Subclass:

Circle, Polygon

Indirect Subclass:

Point

The base class for bodies used to detect collisions

Static Method Summary

Static Public Methods
public static

Creates a Result used to collect the detailed results of a collision test

Constructor Summary

Public Constructor
public

constructor(x: Number, y: Number, padding: Number)

Member Summary

Public Members
public

The amount to pad the bounding volume when testing for potential collisions

public

The X coordinate of the body

public

The Y coordinate of the body

Method Summary

Public Methods
public

collides(target: Circle | Polygon | Point, result: Result, aabb: Boolean): Boolean

Determines if the body is colliding with another body

public

Creates a Result used to collect the detailed results of a collision test

public

Returns a list of potential collisions

public

remove()

Removes the body from its current collision system

Static Public Methods

public static createResult() source

Creates a Result used to collect the detailed results of a collision test

Public Constructors

public constructor(x: Number, y: Number, padding: Number) source

Params:

NameTypeAttributeDescription
x Number
  • optional
  • default: 0

The starting X coordinate

y Number
  • optional
  • default: 0

The starting Y coordinate

padding Number
  • optional
  • default: 0

The amount to pad the bounding volume when testing for potential collisions

Public Members

public padding: Number source

The amount to pad the bounding volume when testing for potential collisions

public x: Number source

The X coordinate of the body

public y: Number source

The Y coordinate of the body

Public Methods

public collides(target: Circle | Polygon | Point, result: Result, aabb: Boolean): Boolean source

Determines if the body is colliding with another body

Params:

NameTypeAttributeDescription
target Circle | Polygon | Point

The target body to test against

result Result
  • optional
  • default: null

A Result object on which to store information about the collision

aabb Boolean
  • optional
  • default: true

Set to false to skip the AABB test (useful if you use your own potential collision heuristic)

Return:

Boolean

public createResult() source

Creates a Result used to collect the detailed results of a collision test

public potentials(): Array<Body> source

Returns a list of potential collisions

Return:

Array<Body>

public remove() source

Removes the body from its current collision system