Class: Component

Component

A Component is an object that can be added to an Entity to add behavior to it in a modular fashion. This can be useful to create small pieces of functionality that can be reused often and without extra boilerplate code.

If it implements an onUpdate(dt) function, the update method will be called every frame.

A single Component instance is unique to an Entity and cannot be shared!

Instead of using Object.create, Component subclasses need to be extended using


Component.create(SubComponentClass, props);


<abstract> new Component()

Author:
  • derschmale <http://www.derschmale.com>
See:

Members


entity

The target entity.


onUpdate

If provided, this method will be called every frame, allowing updating the entity.

Methods


onAdded()

Called when this component is added to an Entity.


onRemoved()

Called when this component is removed from an Entity.