mwg API
    Preparing search index...

    Class Toast

    A queued, timed pop-up notification - an achievement unlock, a level-up banner, a "quest complete" toast. The same pop-in/hold/fade-out shape FloatingText already generalizes for a damage number, but queued rather than fire-and-forget: only one toast is ever shown at a time, and a second one landing mid-animation waits its turn instead of overlapping.

    show takes a Container the caller builds and owns (an icon, a label, a whole banner layout) - this owns only the timing, never the content's own shape. Driven directly by update(dt) with a plain phase/elapsed timer, the same shape FloatingText already uses, rather than chained tweens: a single frame boundary between phases keeps the whole sequence exactly reproducible one update call at a time, which a test can drive without waiting on any promise microtask to settle.

    import { Toast } from '@datamoc/mw_games/two-d/ui';
    import { Text2D } from '@datamoc/mw_games/two-d/render';

    const toast = new Toast({ fadeIn: 0.2, hold: 1.5, fadeOut: 0.5 });
    toast.show(new Text2D({ text: 'Achievement unlocked: First Blood' }));

    console.log(toast.isBusy); // true - popping in
    toast.update(1 / 60); // called every frame from the scene's own update(dt)

    Hierarchy

    • Container
      • Toast
    Index
    • get isBusy(): boolean

      true while a toast is showing or waiting in the queue

      Returns boolean

    • queues content to show next, or immediately if nothing is currently showing

      Parameters

      • content: Container

      Returns void