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

Register an event that runs when the canvas resizes.

paramaction- The function that runs when the canvas resizes.

// create a rectangle with screen size
let rectangle = add([
    rect(width(), height()),
    color(GREEN),
]);

// resize the rectangle to screen size
onResize(() => {
    debug.log(`Old Size: ${rectangle.width}x${rectangle.height}`);
    rectangle.width = width();
    rectangle.height = height();
    debug.log(`New Size: ${rectangle.width}x${rectangle.height}`);
});

returnsThe event controller.

sincev3000.0

kaplay logo

Misc

Layer