jetlag2d
    Preparing search index...

    Class ParticleComponent

    ParticleComponent is an AppearanceComponent that draws a batch of small, short-lived "particles" (for things like impact bursts or torch/thruster effects), all emanating from its Actor's RigidBody.

    Index
    • Build a ParticleComponent

      Parameters

      • cfg: {
            angle?: number;
            colors?: (string | number)[];
            fade?: boolean;
            img?: string;
            lifetime?: { max: number; min: number };
            offset?: JLOffset;
            size?: { max: number; min: number };
            speed?: { max: number; min: number };
            spread?: number;
            z?: 0 | 1 | 2 | 4 | -4 | 3 | -3 | -2 | -1;
        }
        • Optionalangle?: number

          The direction (radians) particles are emitted toward, relative to the anchor's own rotation. Default 0 ("forward").

        • Optionalcolors?: (string | number)[]

          Colors to choose from, per-particle (hex numbers or CSS strings)

        • Optionalfade?: boolean

          Should particles fade out over their lifetime? (default true)

        • Optionalimg?: string

          Optional image to use for each particle (defaults to a plain dot, tinted per-particle)

        • Optionallifetime?: { max: number; min: number }

          Range (seconds) of how long a particle lives before disappearing

        • Optionaloffset?: JLOffset

          An offset between the emission point and the RigidBody's center

        • Optionalsize?: { max: number; min: number }

          Range (meters) of how big a particle is

        • Optionalspeed?: { max: number; min: number }

          Range (meters/second) of how fast a particle moves outward

        • Optionalspread?: number

          The total angle (radians) of spread around angle. Default 2*PI (all directions).

        • Optionalz?: 0 | 1 | 2 | 4 | -4 | 3 | -3 | -2 | -1

          An optional z index in the range [-4,4]

      Returns ParticleComponent

    actor?: Actor<unknown>

    The Actor to which this ParticleComponent is attached

    height: number

    Height is a dummy value. We can't know how big the system gets, but AppearanceComponent needs a height, so we just use twice the max size as an estimate

    offset: JLOffset

    An offset between the emission point and the RigidBody's center

    width: number

    Width is a dummy value. We can't know how big the system gets, but AppearanceComponent needs a width, so we just use twice the max size as an estimate

    z: -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4

    Z index of the whole particle system: Must be in the range [-4, 4]

    • Start continuously emitting particles, e.g. for a torch or a thruster

      Parameters

      • particlesPerSecond: number

      Returns void