Function

onLoad

(action: () => void): KEventController | undefined

Register an event that runs when all assets finished loading.

param action- The function to run when the event is triggered.

const bean = add([
    sprite("bean"),
]);

// certain assets related data are only available when the game finishes loading
onLoad(() => {
    debug.log(bean.width)
});

returns The event controller.

since v2000.1

group Events

kaplay logo

Layer

Miscalenous