Shaku

Shaku JS

Back To Table of Content

Resolver

CollisionResolver

The collision resolver is responsible to implement collision detection between pair of shapes of same or different types.

Kind: global class

new CollisionResolver()

Create the resolver.

collisionResolver.setHandler(firstShapeId, secondShapeId, handler)

Set the method used to test collision between two shapes. Note: you don’t need to register the same handler twice for reverse order, its done automatically inside.

Kind: instance method of CollisionResolver

Param Type Description
firstShapeId String The shape identifier the handler recieves as first argument.
secondShapeId String The shape identifier the handler recieves as second argument.
handler function Method to test collision between the shapes. Return false if don’t collide, return either Vector2 with collision position or ‘true’ for collision.

collisionResolver.test(first, second) ⇒ CollisionTestResult

Check a collision between two shapes.

Kind: instance method of CollisionResolver
Returns: CollisionTestResult - collision detection result or null if they don’t collide.

Param Type Description
first CollisionShape First collision shape to test.
second CollisionShape Second collision shape to test.

collisionResolver.testWithHandler(first, second, handler) ⇒ CollisionTestResult

Check a collision between two shapes.

Kind: instance method of CollisionResolver
Returns: CollisionTestResult - collision detection result or null if they don’t collide.

Param Type Description
first CollisionShape First collision shape to test.
second CollisionShape Second collision shape to test.
handler function Method to test collision between the shapes.

collisionResolver.getHandlers()

Get handlers dictionary for a given shape.

Kind: instance method of CollisionResolver