onError(action: (err: Error)=>void): KEventController

Register a custom error handler. Can be used to draw a custom error screen.

paramaction- The function that runs when the program errors.

// Create custom error handler
onError((err) => {
    drawRect({
        width: width(),
        height: height(),
        pos: center(),
        color: RED,
        anchor: `center,
    });

    drawText({
        text: err.message,
        size: 48,
        width: width()/2,
        anchor: `center`,
        align: `center`,
        pos: center(),
        color: BLACK
    });
});

// cause common error
let pos = add([
    pos()
]);

returnsThe event controller.

sincev3000.0

kaplay logo

Misc

Layer