Function

onAdd

(tag: Tag, action: (obj: GameObj) => void): KEventController

Register an event that runs when an object with the provided tag is added.

param tag- The tag to listen for.

param action- The function that runs when an object is added.

// This will run when the object is added.
onAdd("player", () => {
    debug.log("ohhi");
});

add([
    pos(),
    "player"
]);

returns The event controller.

since v2000.0

group Events

Function

onAdd

(action: (obj: GameObj) => void): KEventController

Register an event that runs when an object is added

param action- The tag to match, only called for objects with a matching tag.

param unknown- The function that runs when an object is added.

// This will run when the object is added.
onAdd(() => {
    debug.log("ohhi");
});

add([
    pos(),
]);

returns The event controller.

since v2000.0

group Events

kaplay logo

Layer

Miscalenous