Show:
API

Matter.Detector

The Matter.Detector module contains methods for efficiently detecting collisions between a list of bodies using a broadphase algorithm.

Methods

Matter.Detector._sortCompare

(bodyA, bodyB)
Number private

The comparison function used in the broadphase algorithm. Returns the signed delta of the bodies bounds on the x-axis.

Parameters

Returns

Number

The signed delta used for sorting

Matter.Detector.canCollide

(filterA, filterB)
Bool

Returns true if both supplied collision filters will allow a collision to occur. See body.collisionFilter for more information.

Parameters

Returns

Bool

true if collision can occur

Matter.Detector.clear

(detector)

Clears the detector including its list of bodies.

Parameters

Matter.Detector.collisions

(detector)
Collision[]

Efficiently finds all collisions among all the bodies in detector.bodies using a broadphase algorithm.

Note: The specific ordering of collisions returned is not guaranteed between releases and may change for performance reasons. If a specific ordering is required then apply a sort to the resulting array.

Parameters

Returns

Collision[]

collisions

Matter.Detector.create

(options)
Detector

Creates a new collision detector.

Parameters

Returns

Detector

A new collision detector

Matter.Detector.setBodies

(detector, bodies)

Sets the list of bodies in the detector.

Parameters

Properties / Options

The following properties if specified below are for objects created by Matter.Detector.create and may be passed to it as options.

Detector.bodies

Body[]

The array of Matter.Body between which the detector finds collisions.

Note: The order of bodies in this array is not fixed and will be continually managed by the detector.

Default: []

The array of Matter.Collision found in the last call to Detector.collisions on this detector.

Default: []

Detector.pairs

Pairs | Null

Optional. A Matter.Pairs object from which previous collision objects may be reused. Intended for internal Matter.Engine usage.

Default: null