CollisionComponent

new CollisionComponent(bounds, layers, ignoreLayers)

Create a new collision component.
Parameters:
NameTypeDescription
boundsBoundsBounding box for collision
layersArray.<string>Layers to collide with
ignoreLayersArray.<string>Layers to ignore

Extends

Members

bounds

Get the bounds of the collision.

Methods

check(other, pos) → {Object}

Check for collision with another component.
Parameters:
NameTypeDescription
otherCollisionComponentCollision component to check with
posVec2The position to attempt to move to
Returns:
Object containing collision result
Type: 
Object

destructor()

Handle the deletion of the component.

draw(ctx)

Draw the component.
Parameters:
NameTypeDescription
ctxCanvasRenderingContext2DCanvas context to draw on

drawDebug(ctx)

Draw debugging info for the component.
Parameters:
NameTypeDescription
ctxCanvasRenderingContext2DCanvas context to draw on

init()

Initialize the component.

update(elapsed)

Update the component.
Parameters:
NameTypeDescription
elapsednumberTime since last update cycle in seconds