GameObjRaw:

Base interface of all game objects.

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

Add a child.

since

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

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

remove(obj: GameObj): void

Remove a child.

since

removeAll(tag: Tag): void

Remove all children with a certain tag.

since

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

Get a list of all game objs with certain tag.

since

query(opt: QueryOpt): GameObj[]

Get a list of all game objs with certain properties.

since

children: GameObj[]

Get all children game objects.

since

tags: string[]

Get the tags of a game object.

since

fixedUpdate(): void

Update this game object and all children game objects.

since

update(): void

Update this game object and all children game objects.

since

draw(): void

Draw this game object and all children game objects.

since

drawInspect(): void

Draw debug info in inspect mode

since

is(tag: Tag | Tag[]): boolean

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

use(comp: Comp | Tag): void

Add a component or tag.

unuse(comp: Tag): void

Remove a tag or a component with its id.

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

Register an event.

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

Trigger an event.

destroy(): void

Remove the game obj from scene.

c(id: Tag): Comp | null

Get state for a specific comp.

inspect(): GameObjInspect

Gather debug info of all comps.

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

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

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

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

since

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

since

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

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

since

exists(): boolean

If game obj is attached to the scene graph.

isAncestorOf(obj: GameObj): boolean

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

since

transform: Mat4

Calculated transform matrix of a game object.

since

hidden: boolean

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

paused: boolean

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

id: GameObjID | null

A unique number ID for each game object.

canvas: FrameBuffer | null

The canvas to draw this game object on

since

kaplay logo

Misc