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

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

paramtag- The tag to listen for.

paramaction- 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"
]);

returnsThe event controller.

sincev2000.0

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

Register an event that runs when an object is added

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

paramunknown- The function that runs when an object is added.

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

add([
    pos(),
]);

returnsThe event controller.

sincev2000.0

kaplay logo

Misc

Layer