new Component()
This is the extendable Component class. Typically specific component classes should be created using createComponentClass()
. This method accepts component definitions and creates component classes that can be used to create components by entities. It adds properties and methods that are common to all components so that component definitions can focus on unique properties and methods.
To create an extended component class, use the following syntax:
createComponentClass(componentDefinition, prototype);
componentDefinition
is list of key/value pairs that describe the component's behavior.prototype
is an optional prototype that this component extends. See component-template.js for an example componentDefinition that can be sent into this component class factory.
- Source:
Methods
getAssetList(definition, properties, defaultProperties) → {Array}
This method can be overwritten to provide the list of assets this component requires. This method is invoked when the list of game scenes is created to determine assets for each scene.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
definition |
Object
|
The definition for the component. |
properties |
Object
|
The properties of the Entity. |
defaultProperties |
Object
|
The default properties of the Entity. |
Returns:
- Type:
-
Array
A list of the necessary assets to load.
toJSON() → {Object}
Returns a JSON object describing the component.
- Source:
Returns:
- Type:
-
Object
Returns a JSON definition that can be used to recreate the component.
toString() → {String}
Returns a string describing the component.
- Source:
Returns:
- Type:
-
String
Returns the component type as a string of the form "[Component ComponentType]".