Skip to content

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 ​

ts
new Emitter(options): Emitter;

Defined in: src/particles/Emitter.ts:80

Parameters ​

ParameterType
optionsEmitterOptions

Returns ​

Emitter

Properties ​

emitting ​

ts
emitting: boolean = false;

Defined in: src/particles/Emitter.ts:69

Continuous emission on or off (bursts work either way).


view ​

ts
readonly view: ParticleContainer;

Defined in: src/particles/Emitter.ts:65


x ​

ts
x: number = 0;

Defined in: src/particles/Emitter.ts:66


y ​

ts
y: number = 0;

Defined in: src/particles/Emitter.ts:67

Accessors ​

live ​

Get Signature ​

ts
get live(): number;

Defined in: src/particles/Emitter.ts:93

Particles alive now.

Returns ​

number

Methods ​

burst() ​

ts
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 ​

ParameterType
countnumber
xnumber
ynumber

Returns ​

void


clear() ​

ts
clear(): void;

Defined in: src/particles/Emitter.ts:140

Every particle gone at once (a scene change, a cancelled effect).

Returns ​

void


destroy() ​

ts
destroy(): void;

Defined in: src/particles/Emitter.ts:145

Returns ​

void


setPosition() ​

ts
setPosition(x, y): this;

Defined in: src/particles/Emitter.ts:97

Parameters ​

ParameterType
xnumber
ynumber

Returns ​

this


start() ​

ts
start(): this;

Defined in: src/particles/Emitter.ts:103

Returns ​

this


stop() ​

ts
stop(): this;

Defined in: src/particles/Emitter.ts:109

Stops emitting; the particles in the air live out their lives.

Returns ​

this


update() ​

ts
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 ​

ParameterType
dtnumber
camera?CameraLike

Returns ​

void

Released under the MIT License.