Constructor
new ComponentManager(actor)
Create a new component manager.
Parameters:
Name | Type | Description |
---|---|---|
actor | Actor | Actor to be a part of |
Members
collisionCount
Get the amount of CollisionComponents
count
Get the total number of components.
drawableCount
Get the amount of DrawableComponents.
physicsCount
Get the amount of PhysicsComponents
Methods
destructor()
Call the destructor for all attached components.
drawAll(ctx)
Draw all drawable components.
Parameters:
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D | Canvas context for drawing |
drawDebugAll(ctx)
Draw debug info for all drawable components.
Parameters:
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D | Canvas context for drawing |
forAll(func)
Run a function for each component.
Parameters:
Name | Type | Description |
---|---|---|
func | function | Function to run for each component |
get(id) → {ActorComponent}
Get a specific component.
Parameters:
Name | Type | Description |
---|---|---|
id | string | Identifier of component |
Returns:
Specified component
- Type:
- ActorComponent
getAll() → {IterableIterator.<ActorComponent>}
Get an iterable iterator of all components.
Returns:
All components
- Type:
- IterableIterator.<ActorComponent>
getCollisions() → {IterableIterator.<CollisionComponent>}
Get an iterable iterator of all CollisionComponents.
Returns:
All collision components
- Type:
- IterableIterator.<CollisionComponent>
getDrawables() → {IterableIterator.<DrawableComponent>}
Get an iterable iterator of all DrawableComponents.
Returns:
All drawable components
- Type:
- IterableIterator.<DrawableComponent>
getPhysics() → {IterableIterator.<PhysicsComponent>}
Get an iterable iterator of all PhysicsComponents.
Returns:
All physics components
- Type:
- IterableIterator.<PhysicsComponent>
has(id) → {boolean}
Check if the actor has a component with a specified identifier.
Parameters:
Name | Type | Description |
---|---|---|
id | string | Identifier to check for |
Returns:
Whether actor has component with specified identifier
- Type:
- boolean
remove(id)
Remove a component from the actor.
Parameters:
Name | Type | Description |
---|---|---|
id | string | Identifier of component to remove |
updateAll(elapsed)
Update all components.
Parameters:
Name | Type | Description |
---|---|---|
elapsed | number | Time since last update frame in seconds |