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

Register an event that runs when tab is hidden.

paramaction- The function that is run what the tab is hidden.

// spooky ghost
let ghosty = add([
    pos(center()),
    sprite("ghosty"),
    anchor("center"),
]);

// when switching tabs, this runs
onHide(() => {
    destroy(ghosty);
    add([
        text("There was never aa ghosttttt"),
        pos(center()),
        anchor("center")
    ]);
});

returnsThe event controller.

sincev3001.0

kaplay logo

Misc

Layer