Object_Base Class
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.
Item Index
Methods
Methods
addComponent
-
component
-
id
Adds the specified component to the object.
Parameters:
-
component
ComponentThe component
-
id
StringAn optional unique identifier for the component.
addObject
-
object
Adds an object to the list of sub-objects.
Parameters:
-
object
Object_BaseThe object which should be added.
componentsFromDataBundle
-
data
Deserializes components from a data-bundle object.
Parameters:
-
data
ObjectThe 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
NumberThe object which should be erased.
findComponent
-
name
Searches for the first component with the specified class name.
Parameters:
-
name
StringThe class name of the component.
Returns:
The component or null if a component with the specified class name cannot be found.
findComponentById
-
id
Searches for the component with the specified ID.
Parameters:
-
id
StringThe unique identifier of the component.
Returns:
The component or null if a component with the specified ID cannot be found.
findComponents
-
name
Searches for all components with the specified class name.
Parameters:
-
name
StringThe class name of the components.
Returns:
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
ComponentThe component.
-
index
NumberThe index.
-
id
StringAn 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_BaseThe object which should be inserted.
-
index
NumberThe index.
onDataBundleRestore.
-
Object
-
gs.ObjectCodecContext
Called if this object instance is restored from a data-bundle. It can be used re-assign event-handler, anonymous functions, etc.
Parameters:
-
Object
Objectdata - The data-bundle
-
gs.ObjectCodecContext
Objectcontext - The codec-context.
removeComponent
-
component
Removes a component from the object.
Parameters:
-
component
ComponentThe component to remove.
removeObject
-
object
Removes the specified object from the list of sub-objects.
Parameters:
-
object
Object_BaseThe object which should be removed.
setObject
-
object
-
index
Sets sub-object at the specified index.
Parameters:
-
object
Object_BaseThe object.
-
index
NumberThe 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.