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
The comparison function used in the broadphase algorithm. Returns the signed delta of the bodies bounds on the x-axis.
Returns
The signed delta used for sorting
Matter.Detector.canCollide
Returns true
if both supplied collision filters will allow a collision to occur.
See body.collisionFilter
for more information.
Returns
true
if collision can occur
Matter.Detector.clear
Clears the detector including its list of bodies.
Parameters
-
detector
Detector
Matter.Detector.collisions
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
-
detector
Detector
Returns
collisions
Properties / Options
The following properties if specified below are for objects created by Matter.Detector.create
and may be passed to it as options
.
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: []
Detector.collisions
Collision[]
The array of Matter.Collision
found in the last call to Detector.collisions
on this detector.
Default: []
Optional. A Matter.Pairs
object from which previous collision objects may be reused. Intended for internal Matter.Engine
usage.
Default: null