mwg API
    Preparing search index...

    Class LightningArc

    The position data for a jagged line between two points - a lightning bolt, a tether, a chain lightning link - the temporised two-point visual two-d/render had no helper for. Owns geometry only, the same division Projectile draws for a single moving point: this decides where the line's points are, a caller draws them (through Shape2D's Graphics, typically, one lineTo per point) and decides colour, width and blend mode.

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

    const bolt = new LightningArc({ x: 0, y: 0 }, { x: 100, y: 0 }, { duration: 0.2, segments: 4 });
    console.log(bolt.points.length); // 6 - both endpoints plus 4 interior points

    const expired = bolt.update(0.25);
    console.log(expired); // true - the instant it outlives its duration
    Index
    • Parameters

      • dt: number

      Returns boolean

      true the instant duration elapses, so a caller can remove the arc exactly once