onDestroy(tag: Tag , action: (obj: GameObj )=>void ): KEventController
Register an event that runs when an object with the provided tag is destroyed.
paramtag- The function that runs when an object is destroyed.
// This will run when the tagged object is destroyed.
onDestroy("bean", () => {
debug.log("ohbye");
});
let player = add([
pos(),
"bean"
])
// Destroy the tagged object
destroy(player);
returnsThe event controller.
sincev2000.0
groupEvents
onDestroy(action: (obj: GameObj )=>void ): KEventController
Register an event that runs when an object is destroyed.
paramaction- The tag to match, only called for objects with a matching tag.
paramunknown- The function that runs when an object is destroyed.
// This will run when the object is destroyed.
onDestroy(() => {
debug.log("ohbye");
});
let ghosty = add([
pos(),
]);
// Destroy the object
destroy(ghosty);
returnsThe event controller.
groupEvents