new CollisionComponent(bounds, layers, ignoreLayers)
Create a new collision component.
Parameters:
Name | Type | Description |
---|---|---|
bounds | Bounds | Bounding box for collision |
layers | Array.<string> | Layers to collide with |
ignoreLayers | Array.<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:
Name | Type | Description |
---|---|---|
other | CollisionComponent | Collision component to check with |
pos | Vec2 | The position to attempt to move to |
Returns:
Object containing collision result
- Type:
- Object
destructor()
Handle the deletion of the component.
- Overrides
draw(ctx)
Draw the component.
Parameters:
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D | Canvas context to draw on |
- Overrides
drawDebug(ctx)
Draw debugging info for the component.
Parameters:
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D | Canvas context to draw on |
- Overrides
init()
Initialize the component.
- Overrides
update(elapsed)
Update the component.
Parameters:
Name | Type | Description |
---|---|---|
elapsed | number | Time since last update cycle in seconds |
- Overrides