Detector

class Detector

the Detector class contains methods for detecting collisions between bodies using a broadphase algorithm.

Constructor


new Detector(world: Container) → {}
Parameters:
Name Type Description
world Container

the physic world this detector is bind to

Summary


Properties from Detector

Public Properties


response detector.js:32
response: ResponseObject

ResponseObject

the default response object used for collisions (will be automatically populated by the collides functions)

Public Methods


collides detector.js:61
collides(bodyA: Body, bodyB: Body) → {boolean}

detect collision between two bodies.

Parameters:
Name Type Description
bodyA Body

a reference to body A.

bodyB Body

a reference to body B.

Returns:
Type Description
boolean

true if colliding

shouldCollide detector.js:40
shouldCollide(a: Renderable | Container | Entity | Sprite | NineSliceSprite, b: Renderable | Container | Entity | Sprite | NineSliceSprite) → {boolean}

determine if two objects should collide (based on both respective objects body collision mask and type).
you can redefine this function if you need any specific rules over what should collide with what.

Parameters:
Name Type Description
a Renderable | Container | Entity | Sprite | NineSliceSprite

a reference to the object A.

b Renderable | Container | Entity | Sprite | NineSliceSprite

a reference to the object B.

Returns:
Type Description
boolean

true if they should collide, false otherwise


Powered by webdoc!