Particles
Particles can be used to generate dust, smoke, or fire effects in your games.
Particles
The easiest way to create a ParticleEmitter is to use the Particle Tester to generate code for emitters.
Example: Adding an emitter
js
const actor = new ex.Actor(...);const emitter = new ex.ParticleEmitter(...);emitter.emitterType = ex.EmitterType.Circle; // Shape of emitter nozzleemitter.radius = 5;emitter.minVel = 100;emitter.maxVel = 200;emitter.minAngle = 0;emitter.maxAngle = Math.PI * 2;emitter.emitRate = 300; // 300 particles/secondemitter.opacity = 0.5;emitter.fadeFlag = true; // fade particles overtimeemitter.particleLife = 1000; // in milliseconds = 1 secemitter.maxSize = 10; // in pixelsemitter.minSize = 1;emitter.particleColor = ex.Color.Rose;// set emitter settingsemitter.isEmitting = true; // should the emitter be emitting// add the emitter as a child actor, it will draw on top of the parent actor// and move with the parentactor.add(emitter);// or, alternatively, add it to the current sceneengine.add(emitter);
js
const actor = new ex.Actor(...);const emitter = new ex.ParticleEmitter(...);emitter.emitterType = ex.EmitterType.Circle; // Shape of emitter nozzleemitter.radius = 5;emitter.minVel = 100;emitter.maxVel = 200;emitter.minAngle = 0;emitter.maxAngle = Math.PI * 2;emitter.emitRate = 300; // 300 particles/secondemitter.opacity = 0.5;emitter.fadeFlag = true; // fade particles overtimeemitter.particleLife = 1000; // in milliseconds = 1 secemitter.maxSize = 10; // in pixelsemitter.minSize = 1;emitter.particleColor = ex.Color.Rose;// set emitter settingsemitter.isEmitting = true; // should the emitter be emitting// add the emitter as a child actor, it will draw on top of the parent actor// and move with the parentactor.add(emitter);// or, alternatively, add it to the current sceneengine.add(emitter);