Kiwi.ComponentManager Class
The component manager is a class that is used to handle components that are active on a particular object. Any object that has a component manager attached to it can use components. If you want to check to see if a particular component is on an object you can ask the component manager.
The component manager is updated once per frame (as part of its owner's update), and updates all active components. This is very useful for creating modular, customised behaviors on entities.
Constructor
Kiwi.ComponentManager
-
type
-
owner
Parameters:
-
type
Number- The type of object that this component manager's owner is.
-
owner
Object- The owner of this component manager.
Returns:
Item Index
Methods
Properties
Methods
add
-
component
Adds a Component to the manager.
Parameters:
-
component
Kiwi.ComponentThe component to add
Returns:
The component that was added
addBatch
-
value
Adds a batch of components to the manager at a single time.
Parameters:
-
value
Kiwi.Component multipleThe component/s that you would like to add.
getComponent
-
value
Get an existing component that has been added to the layer by its name
Parameters:
-
value
StringThe component name
Returns:
The component, if found, otherwise null
hasActiveComponent
-
value
Returns true if this contains the component given and the component is active, false otherwise.
Parameters:
-
value
StringThe name of the component.
Returns:
true if this manager contains the component and it is active, false otherwise.
hasComponent
-
value
Returns true if this contains the component given, false otherwise.
Parameters:
-
value
Stringthe name of the component
Returns:
True if this component manager contains the given component, false otherwise.
objType
()
String
public
Returns the type of this object
Returns:
"ComponentManager"
postRender
()
public
Calls postRender on all active Components
postUpdate
()
public
Calls postUpdate on all active Components
preRender
()
public
Calls preRender on all active Components
preUpdate
()
public
Calls preUpdate on all active Components
removeAll
-
[destroy=true]
Removes all of the components from the component manager.
Parameters:
-
[destroy=true]
Boolean optionalIf true will destroy all components
removeComponent
-
component
-
[destroy=true]
Removes a component from the component manager
Parameters:
-
component
Kiwi.ComponentThe component to be removed.
-
[destroy=true]
Boolean optionalIf the destroy method is to be called on the component when it is removed.
Returns:
true if the component was removed successfully
removeComponentByName
-
name
-
[destroy=true]
Removes a component based on its name
Parameters:
-
name
StringThe name of the component to be removed
-
[destroy=true]
Boolean optionalIf the destroy method is to be called on the component when it is removed.
Returns:
true if the component was removed successfully
render
()
public
Renders all active Components
update
()
public
Calls update on all active Components
Properties
_components
Kiwi.Component
private
A list of all components that are currently on the ComponentManager
_owner
Object
private
The owner of this Component Manager
_type
Number
private
The type of this object.