API Docs for:
Show:

Object_Base Class

Module: gs

The base class for all game objects. A game object itself doesn't implement any game logic but uses components and sub-objects for that.

Methods

addComponent

(
  • component
  • id
)

Adds the specified component to the object.

Parameters:

  • component Component

    The component

  • id String

    An optional unique identifier for the component.

addObject

(
  • object
)

Adds an object to the list of sub-objects.

Parameters:

componentsFromDataBundle

(
  • data
)

Deserializes components from a data-bundle object.

Parameters:

  • data Object

    The data-bundle object.

componentsToDataBundle

(
  • type
)

Serializes components of a specified type to a data-bundle. A component needs to implement the toDataBundle method for correct serialization.

Parameters:

  • type String
    • A component class name.

Returns:

A data bundle.

dispose

()

Disposes the object with all its components and sub-objects. A disposed object will be removed from the parent automatically.

disposeComponents

() protected

Disposes all components

disposeObjects

() protected

Disposes all sub-objects.

eraseObject

(
  • object
)

Erases the object at the specified index. The list size will not be changed but the the value at the index will be set to null.

Parameters:

  • object Number

    The object which should be erased.

findComponent

(
  • name
)
Component

Searches for the first component with the specified class name.

Parameters:

  • name String

    The class name of the component.

Returns:

Component:

The component or null if a component with the specified class name cannot be found.

findComponentById

(
  • id
)
Component

Searches for the component with the specified ID.

Parameters:

  • id String

    The unique identifier of the component.

Returns:

Component:

The component or null if a component with the specified ID cannot be found.

findComponents

(
  • name
)
Array

Searches for all components with the specified class name.

Parameters:

  • name String

    The class name of the components.

Returns:

Array:

The components or null if no component with the specified class name has been found.

fullRefresh

()

Starts a full-refresh on all sub-objects

fullUpdate

()

Updates the object with all parent- and sub-objects.

insertComponent

(
  • component
  • index
  • id
)

Inserts a component at the specified index.

Parameters:

  • component Component

    The component.

  • index Number

    The index.

  • id String

    An optional unique identifier for the component.

insertObject

(
  • object
  • index
)

Inserts an object into the list of sub-objects at the specified index.

Parameters:

  • object Object_Base

    The object which should be inserted.

  • index Number

    The index.

onDataBundleRestore.

(
  • Object
  • gs.ObjectCodecContext
)

Provided by the vn module.

Called if this object instance is restored from a data-bundle. It can be used re-assign event-handler, anonymous functions, etc.

Parameters:

  • Object Object

    data - The data-bundle

  • gs.ObjectCodecContext Object

    context - The codec-context.

removeComponent

(
  • component
)

Removes a component from the object.

Parameters:

  • component Component

    The component to remove.

removeObject

(
  • object
)

Removes the specified object from the list of sub-objects.

Parameters:

  • object Object_Base

    The object which should be removed.

setObject

(
  • object
  • index
)

Sets sub-object at the specified index.

Parameters:

  • object Object_Base

    The object.

  • index Number

    The index.

setup

()

Calls setup-routine on all components.

update

()

Updates the object and all its components. This method is called automatically by the parent or ObjectManager so in regular it is not necessary to call it manually.

Properties

active

Unknown

Default: true Indicates if the game object is active. An inactive game object will not be updated.

components

gs.Component

Default: [] A list of components defining the logic/behavior and appearance of the game object.

componentsById

Object

Default: [] All associated components by their ID.

disposed

Boolean

Default: false Indicates if the game object id disposed. A disposed game object cannot be used anymore.

group

string The game object's group. To get all object's of a specific group the gs.ObjectManager.objectsByGroup property can be used.

Default: null

id

String

Default: null The game object's UID (Unique ID)

initialized

Boolean

Default: true Indicates if the game object and its components have been initialized.

needsSort

Boolean

Default: true Indicates if the list of sub-objects needs to be sorted by order because of a change.

needsSort

Boolean

Default: true Indicates if the UI object needs to be updated.

order

Number

Default: 0 Controls the update-order. The smaller the value the earlier the game object is updated before other game objects are updated.

parent

gs.Object_Base

Default: null The parent object if the game object is a sub-object of another game object.

rIndex

Number

Default: 0 Holds the render-index if the game object has a graphical representation on screen. The render-index is the index of the game object's graphic-object(gs.GraphicObject) in the current list of graphic-objects. The render-index is read-only. Setting the render-index to a certain value has no effect.

subObjects

gs.Object_Base

Default: [] A list of game-objects grouped under this game object.