GameObjRaw:

Base interface of all game objects.

sincev2000.0

add<T>(comps?: CompList | GameObj): GameObj<T>

Add a child.

paramcomps- The components to add.

returnsThe added game object.

sincev3000.0

readd<T>(obj: GameObj): GameObj<T>

Remove and re-add the game obj, without triggering add / destroy events.

paramobj- The game object to re-add.

returnsThe re-added game object.

sincev3000.0

remove(obj: GameObj): void

Remove a child.

paramobj- The game object to remove.

sincev3000.0

removeAll(tag: Tag): void

Remove all children with a certain tag.

paramtag- The tag to remove.

sincev3000.0

removeAll(): void

Remove all children.

sincev3000.0

get(tag: Tag | Tag[], opts?: GetOpt): GameObj[]

Get a list of all game objs with certain tag.

paramtag- The tag to get.

sincev3000.0

query(opt: QueryOpt): GameObj[]

Get a list of all game objs with certain properties.

paramopt- The properties to get.

sincev3001.0

children: GameObj[]

readonlyGet all children game objects.

sincev3000.0

tags: string[]

readonlyGet the tags of a game object. For update it, use `tag()` and `untag()`.

sincev3001.0

fixedUpdate(): void

Update this game object and all children game objects.

sincev3001.0

update(): void

Update this game object and all children game objects.

sincev3000.0

draw(): void

Draw this game object and all children game objects.

sincev3000.0

drawInspect(): void

Draw debug info in inspect mode

sincev3000.0

use(comp: Comp | Tag): void

Add a component.

const obj = add([
   sprite("bean"),
]);

// Add opacity
obj.use(opacity(0.5));

sincev2000.0

unuse(comp: Tag): void

Remove a component with its id (the component name)

paramcomp- The component id to remove. It means the name, if sprite, then it's "sprite".

// Remove sprite component
obj.unuse("sprite");

sincev2000.0

has(compId: string | string[], op?: and | or): boolean

Check if game object has a certain component.

paramcompId- The component id(s) to check.

paramop- The operator to use when searching for multiple components. Default is "and".

// Check if game object has sprite component
if(obj.has("sprite")) {
    debug.log("has sprite component");
}

// Check if game object has tags
obj.has(["tag1", "tag2"]); // AND, it has both tags
obj.has(["tag1", "tag2"], "or"); // OR, it has either tag1 or tag2

returnstrue if has the component(s), false otherwise.

sincev3001.0.5

experimentalThis feature is in experimental phase, it will be fully released in v3001.1.0

tag(tag: Tag | Tag[]): void

Add a tag(s) to the game obj.

paramtag- The tag(s) to add.

// add enemy tag
obj.tag("enemy");

// add multiple tags
obj.tag(["enemy", "boss"]);

sincev3001.0.5

experimentalThis feature is in experimental phase, it will be fully released in v3001.1.0

untag(tag: Tag | Tag[]): void

Remove a tag(s) from the game obj.

paramtag- The tag(s) to remove.

// remove enemy tag
obj.untag("enemy");

// remove multiple tags
obj.untag(["enemy", "boss"]);

sincev3001.0.5

experimentalThis feature is in experimental phase, it will be fully released in v3001.1.0

is(tag: Tag | Tag[], op?: and | or): boolean

If there's certain tag(s) on the game obj.

paramtag- The tag(s) for checking.

paramop- The operator to use when searching for multiple tags. Default is "and".

sincev3001.0.5

experimentalThis feature is in experimental phase, it will be fully released in v3001.1.0

on(event: string, action: (args: any)=>void): KEventController

Register an event.

paramevent- The event name.

paramaction- The action to run when event is triggered.

returnsThe event controller.

sincev2000.0

trigger(event: string, args: any): void

Trigger an event.

paramevent- The event name.

parmargs - The arguments to pass to the event action.

sincev2000.0

destroy(): void

Remove the game obj from scene.

sincev2000.0

c(id: string): Comp | null

Get state for a specific comp.

paramid- The component id.

sincev2000.0

inspect(): GameObjInspect

Gather debug info of all comps.

sincev2000.0

onAdd(action: ()=>void): KEventController

Register an event that runs when the game obj is added to the scene.

returnsThe event controller.

sincev2000.0

onUpdate(action: ()=>void): KEventController

Register an event that runs every frame as long as the game obj exists.

returnsThe event controller.

sincev2000.1

onDraw(action: ()=>void): KEventController

Register an event that runs every frame as long as the game obj exists (this is the same as `onUpdate()`, but all draw events are run after all update events).

returnsThe event controller.

sincev2000.1

onDestroy(action: ()=>void): KEventController

Register an event that runs when the game obj is destroyed.

returnsThe event controller.

sincev2000.1

onUse(action: (id: string)=>void): KEventController

Register an event that runs when a component is used.

returnsThe event controller.

sincev3001.0

onUnuse(action: (id: string)=>void): KEventController

Register an event that runs when a component is unused.

returnsThe event controller.

sincev3001.0

exists(): boolean

If game obj is attached to the scene graph.

returnstrue if attached, false otherwise.

sincev2000.0

isAncestorOf(obj: GameObj): boolean

Check if is an ancestor (recursive parent) of another game object

returnstrue if is ancestor, false otherwise.

sincev3000.0

transform: Mat4

Calculated transform matrix of a game object.

sincev3000.0

hidden: boolean

If draw the game obj (run "draw" event or not).

sincev2000.0

paused: boolean

If update the game obj (run "update" event or not).

sincev2000.0

id: GameObjID | null

A unique number ID for each game object.

sincev2000.0

canvas: FrameBuffer | null

The canvas to draw this game object on

sincev3001.0