mwg API
    Preparing search index...

    Class SpriteAttachment

    Ties a second sprite's position to a first one's, with its own offset and its own optional lifetime - a shadow flat beneath a unit, a status icon floating above it, a shield glyph at a corner. StatusVisuals only tints a sprite that already exists; this is for a sprite that is its own thing, positioned relative to an owner rather than drawn as part of it.

    Renderer-neutral by the same design Projectile and LightningArc use: it takes any { x, y } point (a real Pixi Sprite, a plain object, a test double) and only ever writes to it, so it needs no renderer to construct or test. Z-order and parenting stay the caller's, for the same reason Halo leaves them: whether a shadow is added before or after its unit is a per-game drawing decision, not something a framework should guess.

    import { SpriteAttachment } from '@datamoc/mw_games/two-d/render';

    declare const shadowSprite: { x: number; y: number };
    declare const statusIcon: { x: number; y: number };

    const shadow = new SpriteAttachment(shadowSprite, { offsetY: 4 });
    const poisoned = new SpriteAttachment(statusIcon, { offsetY: -20, duration: 3 });

    shadow.follow(100, 200);
    poisoned.follow(100, 200);

    const expired = poisoned.update(1 / 60);
    console.log(expired); // false - not yet 3 seconds in
    Index
    • puts the attachment where its owner stands, with whatever offset it was built with

      Parameters

      • ownerX: number
      • ownerY: number

      Returns this

    • Parameters

      • dt: number

      Returns boolean

      true the instant duration elapses, so a caller can remove it exactly once; always false with no duration