Class: CollisionDetector

hcje/collisions.CollisionDetector(masterCollider)

Class to manage collisions. Instances can be added to an module:hcje/sprites.Sprite.

Constructor

new CollisionDetector(masterCollider)

Construct the collider.

Parameters:
Name Type Description
masterCollider module:hcje/collisions~Collider

main collider which tests for collisions.

Implements:
Source:

Methods

addTarget(targetCollider)

Add target. The target is added to a Map using the target's sprite property as a key. As such, each sprite can only occur once even if a different callback is used.

Parameters:
Name Type Description
targetCollider module:hcje/collisions~Collider

the collision target which will be checked when collisions are detected.

Source:

detect()

Look for collisions. Note that if a sprite is marked as killed, it is removed from the list of targets. Likewise no collisions are detected if the controlling sprite has been killed. In that case all targets are removed from its map.

Source:

removeTargetSprite(sprite)

Remove a target sprite. Note that targets are keyed by the sprite, so only the sprite object is required to remove it.

Parameters:
Name Type Description
sprite module:hcje/sprites~Sprite

the sprite to remove.

Source: