API Docs for:
Show:

ObjectManager Class

Module: gs

Manages game objects by updating if necessary and offering methods to add or remove game objects. All game objects are sorted by the order-property to give control over the update-order.

A game object can registered under a unique ID and then easily accessed using that ID. If an object gets registered, a global variable $ is created as well. However, that global variable is only for the use in property-bindings used for In-Game UI. See ui.Component_BindingHandler.

In addition, a game object can be assigned to a group like for example a set of UI toggle-buttons can be assigned to the same group and then easily accessed later using gs.ObjectManager.objectsByGroup method.

Methods

add

(
  • object
)

Adds a game object to the manager. The game object is then automatically updated by the manager.

Parameters:

  • object gs.Object_Base
    • The game object to add.

addObject

(
  • object
)

Adds a game object to the manager. The game object is then automatically updated by the manager.

Parameters:

  • object gs.Object_Base
    • The game object to add.

addToGroup

(
  • object
  • group
)

Adds an object to a specified object-group.

Parameters:

  • object gs.Object_Base
    • The game object to add.
  • group String
    • The group to assign game object to.

byId

(
  • id
)
gs.Object_Base

Gets an object by ID.

Parameters:

  • id String
    • The ID of the game object to get.

Returns:

gs.Object_Base:

The game object or null if no game object is registered for the specified ID.

dispose

()

Disposes the manager and all assigned game objects.

disposeObjects

()

Disposes all assigned game objects.

objectById

(
  • id
)
gs.Object_Base

Gets an object by ID.

Parameters:

  • id String
    • The ID of the game object to get.

Returns:

gs.Object_Base:

The game object or null if no game object is registered for the specified ID.

objectsByGroup

(
  • group
)
gs.Object_Base

Gets all object of a specified object-group.

Parameters:

  • group String
    • The object-group.

Returns:

gs.Object_Base:

The game objects belonging to the specified group.

registerObject

()

Registers an object.

remove

(
  • object
)

Removes a game object to the manager. The game object is then no longer automatically updated or disposed by the manager.

Parameters:

  • object gs.Object_Base
    • The game object to remove.

removeObject

(
  • object
)

Removes a game object to the manager. The game object is then no longer automatically updated or disposed by the manager.

Parameters:

  • object gs.Object_Base
    • The game object to remove.

setObjectById

(
  • object
  • id
)

Sets the object for an ID.

Parameters:

  • object gs.Object_Base
    • The game object to set.
  • id String
    • The ID for the game object.

unregisterObject

()

Unregisters an object.

update

()

Updates the manager and all assigned game objects in the right order.

Properties

active

Boolean

Indicates if the ObjectManager is active. If false the game objects are not updated.

active

Boolean

Indicates if the ObjectManager needs to sort the game objects.

current

gs.ObjectManager static

Stores the current default ObjectManager.

objects

gs.Object_Base

All game objects to manage.

objectsByGroup_

Object

All game objects by group.

objectsById

Object

All game objects by ID.