A themed loading view driven by LoadQueue.snapshot, with game-owned retry/cancel hooks.
LoadQueue.snapshot
import { LoadingScreen } from '@datamoc/mw_games/two-d/ui';import { LoadQueue } from '@datamoc/mw_games/core';const queue = new LoadQueue();queue.add({ id: 'tileset', run: async () => { await Promise.resolve(); } });const screen = new LoadingScreen({ width: 320, height: 200, title: 'Loading', onRetry: () => queue.retry(), onCancel: () => queue.cancel(),});const unbind = screen.bind(queue); // starts tracking queue.changedawait queue.start();unbind(); // call when the loading scene closes Copy
import { LoadingScreen } from '@datamoc/mw_games/two-d/ui';import { LoadQueue } from '@datamoc/mw_games/core';const queue = new LoadQueue();queue.add({ id: 'tileset', run: async () => { await Promise.resolve(); } });const screen = new LoadingScreen({ width: 320, height: 200, title: 'Loading', onRetry: () => queue.retry(), onCancel: () => queue.cancel(),});const unbind = screen.bind(queue); // starts tracking queue.changedawait queue.start();unbind(); // call when the loading scene closes
Connects the screen to one queue and returns the cleanup needed when its scene closes.
invoke from a game-owned cancel button or keyboard binding
invoke from a game-owned retry button or keyboard binding
A themed loading view driven by
LoadQueue.snapshot, with game-owned retry/cancel hooks.Example