onLoading(action: (progress: number)=>void): KEventController

Register an event that runs every frame when assets are initially loading. Can be used to draw a custom loading screen.

paramaction- The function that runs when assets are loading.

```
// progress bar
onLoading((progress) => {
    // Background of the bar
    drawRect({
        width: 240,
        height: 40,
        pos: center().add(-120,0),
        color: BLACK,
        anchor: `left,
    });
    // Progress of the bar
    drawRect({
        width: map(progress, 0, 1, 0, 220),
        height: 32,
        pos: center().add(-116, 0),
        color: BLUE,
        anchor: `left
    });
});

returnsThe event controller.

sincev3000.0

kaplay logo

Misc

Layer