mwg API
    Preparing search index...

    Class Meter

    A discrete meter: N icons with a value filled, the Zelda heart row or star rating to Bar's continuous fill. Fractions clip mid-icon through a mask, so halves (or any fraction) work identically for flat shapes and game-supplied textures, with no extra half-state art to author.

    Flat icons are theme-drawn pips; game art arrives as a filledTexture/emptyTexture pair, which must come together - one without the other throws, since a half-drawn meter would only guess. Colour follows the theme the way Bar does unless the game passes its own, and a passed colour survives later theme changes.

    import { Meter } from '@datamoc/mwg/two-d/ui';

    const hearts = new Meter({ count: 5, value: 3 });

    hearts.setValue(2.5); // down to two and a half hearts
    console.log(hearts.value); // 2.5

    Hierarchy

    • Container
      • Meter
    Index
    • get color(): number

      the resolved filled colour: the explicit one, or the theme's highlight

      Returns number

    • Removes all internal references and listeners as well as removes children from the display list. Do not use a Container after calling destroy.

      Parameters

      • Optionaloptions: DestroyOptions

        Options parameter. A boolean will act as if all options have been set to that value

      Returns void

      container.destroy();
      container.destroy(true);
      container.destroy({ children: true });
      container.destroy({ children: true, texture: true, textureSource: true });
    • Parameters

      • size: number
      • gap: number = ...

      Returns void

    • Recolours the fill at runtime, counting as explicit exactly as passing color does, so a later theme change cannot throw the game's own colour away.

      Parameters

      • color: number

      Returns void

    • Parameters

      • value: number
      • count: number = ...

      Returns void