Class: ComponentGroup

Class: ComponentGroup

ComponentGroup

new ComponentGroup()

Represents the group of components. Basically it's a criteria for finding Entity. ComponentGroup has three BitSet which will be used to search Entity: contain, intersect, exclude. contain will only match if a Entity has all the Component in BitSet. intersect will match if a Entity has at least one of the Component in BitSet. exclude will match if a Entity doesn't have a Component in BitSet. This class can be generated by a ComponentGroup.createBuilder.

Source:
See:

Extends

Classes

Builder

Members

<private> _engine :Engine

The Engine associated with this object.

Type:
Source:

contain :BitSet

The 'contain' criteria. This will only match if a Entity has all the Component in this BitSet.

Type:
Source:

exclude :BitSet

The 'exclude' criteria. This will match if a Entity doesn't have a Component in this BitSet.

Type:
Source:

<readonly> id :Number

The ID of this object. This will be given by Engine, and it shouldn't be edited.

Type:
  • Number
Source:

intersect :BitSet

The 'intersect' criteria. This will match if a Entity has at least one of the Component in BitSet.

Type:
Source:

Methods

<static> createBuilder(engine) → {ComponentGroup.Builder}

Creates a Builder object that helps to make ComponentGroup object.

Parameters:
Name Type Description
engine Engine

The Engine which will use this ComponentGroup.

Source:
Returns:

A Builder object.

Type
ComponentGroup.Builder

emit(event)

Emits the event. This will trigger all the listener with that event type. You can supply listener function's arguments by appending arguments after the 'event' parameter.

Parameters:
Name Type Description
event String

The name of the event.

args...

Arguments to supply to listeners.

Inherited From:
Source:

equals(o) → {Boolean}

Checkes whether if the ComponentGroup equals the other. The ComponentGroups are equal if they have same criteria.

Parameters:
Name Type Description
o ComponentGroup

The other ComponentGroup.

Source:
Returns:

Whether if the ComponentGroups are equal.

Type
Boolean

listeners(event) → {Array}

Returns the array of listeners with specified event type.

Parameters:
Name Type Description
event String

The name of the event.

Inherited From:
Source:
Returns:

An array holding event listeners.

Type
Array

matches(entity) → {Boolean}

Checkes whether if the Entity matches its criteria.

Parameters:
Name Type Description
entity Entity

The Entity to check.

Source:
Returns:

Whether if the Entity matches its criteria.

Type
Boolean

on(event, listener)

Registers a listener.

Parameters:
Name Type Description
event String

The name of the event.

listener function

The function to be triggered.

Inherited From:
Source:

once(event, listener)

Registers a one-time listener. The listener will be removed after being triggered once.

Parameters:
Name Type Description
event String

The name of the event.

listener function

The function to be triggered.

Inherited From:
Source:

removeAllListeners(event)

Removes all the listener with specified event type. If event parameter is not set, it will remove all the listener of all types.

Parameters:
Name Type Argument Description
event String <optional>

The name of the event.

Inherited From:
Source:

removeListener(event, listener)

Removes the listener.

Parameters:
Name Type Description
event String

The name of the event.

listener function

The function to be removed.

Inherited From:
Source:

Events

entityAdded

This event is fired to ComponentGroup when a Entity matching its criteria has added to Engine.

Type:
Source:
See:

entityRemoved

This event is fired to ComponentGroup when a Entity matching its criteria has removed from Engine.

Type:
Source:
See: