Skip to content

Particles

Marc Flerackers edited this page Jun 22, 2024 · 5 revisions

Particles is a component so that transformation can be optimized and all particles can be drawn at once.

export type ParticlesOpt = {
    maxParticles: number;
    emitterShape?: ShapeType;
    emitterLifetime?: number;
    emissionRate: number;
    emissionDirection: number;
    emissionSpread: number;
    particleLifeTime: [number, number];
    particleSpeed: [number, number];
    particleColors?: Color[];
    particleOpacities?: number[];
    particleSprites?: string[];
};

export interface ParticlesComp extends Comp {
    emit(n: number): void;
    onEnd(cb: () => void): void;
}

export function particles(opt: ParticlesOpt): ParticlesComp

If needed a separate emitter component can be made to emit particles as objects. However this will have worse performance and as such should not be encouraged.

Clone this wiki locally