mwg API
    Preparing search index...

    Class Flights

    Owns the projectile flights a game has in the air: one add per shot, one update(dt) driving them all, onArrive dispatched exactly once per arrival, and no bookkeeping left to the caller.

    Ownership follows who made the sprite. A sprite you pass stays yours - the manager positions it but never parents or destroys it, so layering and scene teardown stay the caller's. A texture builds a manager sprite instead: parented here and destroyed on arrival, cancel or clear. Destroying the Flights node itself clears first, so manager-built sprites never outlive it.

    import { Flights } from '@datamoc/mwg/two-d/render';
    import type { Container2D } from '@datamoc/mwg/two-d/render';

    declare const layer: Container2D;
    declare const bolt: { x: number; y: number };

    const flights = new Flights();
    layer.addChild(flights);

    const flight = flights.add(bolt, { x: 0, y: 0 }, { x: 200, y: 0 }, {
    speed: 400,
    onArrive: () => console.log('hit'),
    });
    flights.update(1 / 60);
    console.log(flights.count, flight.done); // 1 false - still flying
    flight.cancel();
    flights.clear();

    Hierarchy

    • Container
      • Flights
    Index
    • Parameters

      • Optionaloptions: ContainerOptions<ContainerChild>

      Returns Flights

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

      Returns void

      container.destroy();
      container.destroy(true);
      container.destroy({ children: true });
      container.destroy({ children: true, texture: true, textureSource: true });
    • drives every live flight, then forgets the arrived ones (arrival first, callback after)

      Parameters

      • dt: number

      Returns void