1681-engine / index / Emitter
Class: Emitter ​
Defined in: src/particles/Emitter.ts:64
A source of smooth sprite particles for any art style: sparks, smoke, dust, magic. Particles live in world coordinates, so moving the emitter (x, y) trails new ones behind it instead of dragging the old ones along.
Drawn by one Pixi ParticleContainer (view): add it to a scene's root, and call update(dt, camera) once a frame. Particle objects are pooled and their colour is written straight into Pixi's packed field, so a steady emitter allocates nothing per frame. Spawning asks the shared ParticleBudget first, and off-screen emitters neither spawn nor draw.
Constructors ​
Constructor ​
new Emitter(options): Emitter;Defined in: src/particles/Emitter.ts:80
Parameters ​
| Parameter | Type |
|---|---|
options | EmitterOptions |
Returns ​
Emitter
Properties ​
emitting ​
emitting: boolean = false;Defined in: src/particles/Emitter.ts:69
Continuous emission on or off (bursts work either way).
view ​
readonly view: ParticleContainer;Defined in: src/particles/Emitter.ts:65
x ​
x: number = 0;Defined in: src/particles/Emitter.ts:66
y ​
y: number = 0;Defined in: src/particles/Emitter.ts:67
Accessors ​
live ​
Get Signature ​
get live(): number;Defined in: src/particles/Emitter.ts:93
Particles alive now.
Returns ​
number
Methods ​
burst() ​
burst(
count,
x?,
y?
): void;Defined in: src/particles/Emitter.ts:116
count particles at once, at the emitter or at (x, y). Thinned under reduced effects; skipped off screen.
Parameters ​
| Parameter | Type |
|---|---|
count | number |
x | number |
y | number |
Returns ​
void
clear() ​
clear(): void;Defined in: src/particles/Emitter.ts:140
Every particle gone at once (a scene change, a cancelled effect).
Returns ​
void
destroy() ​
destroy(): void;Defined in: src/particles/Emitter.ts:145
Returns ​
void
setPosition() ​
setPosition(x, y): this;Defined in: src/particles/Emitter.ts:97
Parameters ​
| Parameter | Type |
|---|---|
x | number |
y | number |
Returns ​
this
start() ​
start(): this;Defined in: src/particles/Emitter.ts:103
Returns ​
this
stop() ​
stop(): this;Defined in: src/particles/Emitter.ts:109
Stops emitting; the particles in the air live out their lives.
Returns ​
this
update() ​
update(dt, camera?): void;Defined in: src/particles/Emitter.ts:122
Advances by dt seconds. Pass the camera to skip spawning and drawing while everything is off screen.
Parameters ​
| Parameter | Type |
|---|---|
dt | number |
camera? | CameraLike |
Returns ​
void