GameObject
Extends:
Direct Subclass:
Baseclass GameObject which derives from Updateable.
Do not derive this class directly! GameObjects are not managed until they are assigned to a manager. Instead, derive SceneObject or PersistentObject to create objects that exist the scope of a scene, or the scope of the game.
All objects that should exist in the game screen should derive this.
Constructor Summary
Public Constructor | ||
public |
constructor(position: Point, size: Point, rotation: number) Default position, size and rotation of the Object. |
Member Summary
Public Members | ||
public |
|
|
public |
components: {} |
|
public |
transform: * |
Method Summary
Public Methods | ||
public |
addComponent(component: Component): boolean Adds a component to this game object, and keeps reference to it. |
|
public |
getComponent(componentName: string, index: *): * Returns a component of type {componentName}. |
|
public |
hasComponent(componentName: string): boolean Returns a boolean on if there is a component of type {componentName}. |
|
public |
onPause() |
|
public |
Override for Post Update functionality. |
|
public |
Override for Pre Update functionality. |
|
public |
|
|
public |
Called by the GameObject after an update to do default calls for postUpdating. |
|
public |
Called by the GameObject before an update to do default calls for preUpdating. |
|
public |
Removes all components except for the Transform component. |
|
public |
removeComponent(componentID: number): boolean Removes a single component from this GameObject by ID. |
|
public |
removeComponents(componentName: string): boolean Removes all Components of the named type. |
|
public |
update() Rewritten update() functions which is originally defined in Updateable. |
|
public |
Updates all components on this GameObject. |
Inherited Summary
From class Updateable | ||
public |
deregister: * |
|
public |
|
|
public |
|
|
public |
id: * |
|
public |
Cleanup code for when destroying an Updateable. |
|
public |
end() Base call function for when this Updateable is to be ended. |
|
public |
onEnd() Called when the object is being removed or cleaned up from usage. |
|
public |
onPause() Called when the object is intended to be paused. |
|
public |
onStart() Called when the the object is first introduced. |
|
public |
Called when the object is to be unpaused from paused state. |
|
public |
onUpdate() Called on every update within the game, once the object has had onStart called. |
|
public |
pause() Base call function for when this Updateable is to be paused. |
|
public |
start() Base call function for when this Updateable is to be started. |
|
public |
unpause() Base call function for when this Updateable is to be unpaused. |
|
public |
update() Base call function for when this Updateable is to be updated. |
Public Constructors
public constructor(position: Point, size: Point, rotation: number) source
Default position, size and rotation of the Object.
Override:
Updateable#constructorPublic Methods
public addComponent(component: Component): boolean source
Adds a component to this game object, and keeps reference to it. GameObjects will handle their components as they are added to the object.
Params:
Name | Type | Attribute | Description |
component | Component | The component assigned to this object. |
public getComponent(componentName: string, index: *): * source
Returns a component of type {componentName}. The second parameter can determine which Component of that type to return if there are more than 1.
Params:
Name | Type | Attribute | Description |
componentName | string | Name of the component type to return. |
|
index | * | Index of the component to get. Defaults to first component. |
Return:
* |
public hasComponent(componentName: string): boolean source
Returns a boolean on if there is a component of type {componentName}.
Params:
Name | Type | Attribute | Description |
componentName | string | Name of the component type to search for. |
public onPause() source
Called when the object is intended to be paused.
Override:
Updateable#onPausepublic onUnpause() source
Called when the object is to be unpaused from paused state.
Override:
Updateable#onUnpausepublic postUpdate() source
Called by the GameObject after an update to do default calls for postUpdating. Afterwards it calls the overrideable function, onPostUpdate.
public preUpdate() source
Called by the GameObject before an update to do default calls for preUpdating. Afterwards it calls the overrideable function, onPreUpdate.
public removeAllComponents(): boolean source
Removes all components except for the Transform component.
public removeComponent(componentID: number): boolean source
Removes a single component from this GameObject by ID.
Params:
Name | Type | Attribute | Description |
componentID | number | Id of the component to remove. |
public removeComponents(componentName: string): boolean source
Removes all Components of the named type.
Params:
Name | Type | Attribute | Description |
componentName | string | The name of the components to clear. |
public update() source
Rewritten update() functions which is originally defined in Updateable. The GameObject adds a pre and post update function, and respective overrideable callbacks (onPreUpdate and onPostUpdate).