Home Reference Source Test
import GameObject from 'seed-engine/src/object/GameObject.js'
public class | source

GameObject

Extends:

Updateable → GameObject

Direct Subclass:

PersistentObject, SceneObject

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
public

Method Summary

Public Methods
public

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
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
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

Called when the object is intended to be paused.

public

Called when the the object is first introduced.

public

Called when the object is to be unpaused from paused state.

public

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

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#constructor

Params:

NameTypeAttributeDescription
position Point

A point of creation in the world.

size Point

A point representing scale of the object.

rotation number

A number representing angular rotation (in degrees).

Public Members

public className: string source

public components: {} source

public transform: * source

Public 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:

NameTypeAttributeDescription
component Component

The component assigned to this object.

Return:

boolean

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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
componentName string

Name of the component type to search for.

Return:

boolean

true if there is at least one component of this type.

public onPause() source

Called when the object is intended to be paused.

Override:

Updateable#onPause

public onPostUpdate() source

Override for Post Update functionality.

public onPreUpdate() source

Override for Pre Update functionality.

public onUnpause() source

Called when the object is to be unpaused from paused state.

Override:

Updateable#onUnpause

public 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.

Return:

boolean

public removeComponent(componentID: number): boolean source

Removes a single component from this GameObject by ID.

Params:

NameTypeAttributeDescription
componentID number

Id of the component to remove.

Return:

boolean

public removeComponents(componentName: string): boolean source

Removes all Components of the named type.

Params:

NameTypeAttributeDescription
componentName string

The name of the components to clear.

Return:

boolean

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).

Override:

Updateable#update

public updateComponents() source

Updates all components on this GameObject.