Class: Manager

Manager()

This class is responsible for managing all entities and ensuring that systems are updated every frame.

Constructor

new Manager()

Creates a new instance of Manager class
Source:

Classes

Manager

Members

clock :Clock

Master clock for the game
Type:
Source:

(readonly) events :EventDispatcher

Type:
Source:

frameRate :number

Ideal framerate of the manager.Not implemented corrretly. TODO correct it
Type:
  • number
Source:

(readonly) loader :Loader

look at Loader for more info.
Type:
Source:

perf

Source:

playing :boolean

Whether or not the manager is playing.
Type:
  • boolean
Source:

Methods

add(object)

Adds an entity to the manager and initializes it.
Parameters:
Name Type Description
object Entity The entity to add
Source:

addComponent(n, c)

This adds a component to a componentList if the componentList is there else exits without an error. There is no need for you to use this method as it is for internal use only and may change in the future
Parameters:
Name Type Description
n string name of the component
c Component An object implementing Component
Source:

clear()

This removes all of the entities and components from the manager
Source:

getComponentList(n) → {Array.<Component>}

Used to create a componentList in the manager.A component must have the same name as the componentList to be added into it.
Parameters:
Name Type Description
n string The name of the components to store into the created componentlist
Source:
Returns:
An array of components
Type
Array.<Component>

getEntitiesByComponents(comps, entitiesopt, targetopt) → {Array.<Entity>}

Finds the first entity with all the tag and returns it.
Parameters:
Name Type Attributes Default Description
comps Array.<String> An array containing the component names to be searched
entities Array.<Entity> <optional>
Manager#objects The array of entities to search in.Defaults to the manager's entity list
target Array.<Entity> <optional>
Source:
Returns:
Type
Array.<Entity>

getEntitiesByTags(tags, entitiesopt, target) → {Array.<Entity>}

Finds the entities with all the tag and returns them in an array.
Parameters:
Name Type Attributes Default Description
tags Array.<string> An array containing the tags to be searched
entities Array.<Entity> <optional>
Manager#objects The array of entities to search in. Defaults to the manager's entity list
target Array.<Entity>
Source:
Returns:
Type
Array.<Entity>

getEntityByComponents(comps) → {Entity}

Finds the first entity with all the components and returns it.
Parameters:
Name Type Description
comps Array.<String> An array containing the component names to be searched
Source:
Returns:
Type
Entity

getEntityByTags(tags) → {Entity}

Finds the first entity with all the tag and returns it.
Parameters:
Name Type Description
tags Array.<String> An array containing the tags to be searched
Source:
Returns:
Type
Entity

getSystem(n) → {System}

Gets the named system
Parameters:
Name Type Description
n string the name the system was registered with.
Source:
Returns:
Type
System

init()

This initializes the manager. No need to call this function directly. This is called after the preloader finishes loading all its files.
Source:

pause()

This stops the update loop of the manager
Source:

play()

This starts up the update loop of the manager
Source:

query(bound)

Parameters:
Name Type Description
bound BoundingCircle | BoundingBpx
Source:
Returns:
Entity[]

registerSystem(n, sys, cnopt)

Used to register a system
Parameters:
Name Type Attributes Default Description
n string The name for the system
sys System The system to be addad
cn string <optional>
n The componentList name that the system will primarily take care of
Source:

remove(object)

Removes an entity from the manager. Note that this doesn't destroy the entity, only removes it and its components from the manager. To destroy the entity,use `Entity.destroy()` method.
Parameters:
Name Type Description
object Entity The entity to remove
Source:

removeComponent(n, c)

This removes a component from a componentList if the componentList is there else exits without an error. There is no need for you to use this method as it is for internal use only and may change in the future
Parameters:
Name Type Description
n string name of the component *
c Component An object implementing Component interface
Source:

setComponentList(n, arropt)

Used to create a componentList in the manager.componentsA component must have the same name as the componentList to be added into it.
Parameters:
Name Type Attributes Default Description
n string The name of the components to store into the created componentlist
arr Array.<Component> <optional>
[] A reference to the array to store components in.
Source:

unregisterSystem(n) → {void}

Removes a system from the manager.
Parameters:
Name Type Description
n string The name of the system
Source:
Returns:
Type
void