Function
onResize
(action: () => void): KEventControllerRegister an event that runs when the canvas resizes.
param
action- 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}`);
});
returns
The event controller.
since
v3000.0
group
Events