API Docs for: 1.4.0
Show:

Kiwi.ComponentManager Class

Module: Kiwi

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
)
ComponentManager

Parameters:

  • type Number
    • The type of object that this component manager's owner is.
  • owner Object
    • The owner of this component manager.

Returns:

ComponentManager:

Methods

add

(
  • component
)
Kiwi.Component public

Adds a Component to the manager.

Parameters:

Returns:

Kiwi.Component:

The component that was added

addBatch

(
  • value
)
public

Adds a batch of components to the manager at a single time.

Parameters:

  • value Kiwi.Component multiple

    The component/s that you would like to add.

getComponent

(
  • value
)
Kiwi.Component public

Get an existing component that has been added to the layer by its name

Parameters:

  • value String

    The component name

Returns:

Kiwi.Component:

The component, if found, otherwise null

hasActiveComponent

(
  • value
)
Boolean public

Returns true if this contains the component given and the component is active, false otherwise.

Parameters:

  • value String

    The name of the component.

Returns:

Boolean:

true if this manager contains the component and it is active, false otherwise.

hasComponent

(
  • value
)
Boolean public

Returns true if this contains the component given, false otherwise.

Parameters:

  • value String

    the name of the component

Returns:

Boolean:

True if this component manager contains the given component, false otherwise.

objType

() String public

Returns the type of this object

Returns:

String:

"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]
)
public

Removes all of the components from the component manager.

Parameters:

  • [destroy=true] Boolean optional

    If true will destroy all components

removeComponent

(
  • component
  • [destroy=true]
)
Boolean public

Removes a component from the component manager

Parameters:

  • component Kiwi.Component

    The component to be removed.

  • [destroy=true] Boolean optional

    If the destroy method is to be called on the component when it is removed.

Returns:

Boolean:

true if the component was removed successfully

removeComponentByName

(
  • name
  • [destroy=true]
)
Boolean public

Removes a component based on its name

Parameters:

  • name String

    The name of the component to be removed

  • [destroy=true] Boolean optional

    If the destroy method is to be called on the component when it is removed.

Returns:

Boolean:

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.