Skip to content

Particles

jEngine has two particle systems: CPU emitters (particle_emitter), which can collide and spawn sub-emitters, and GPU particles (gpu_particles) for clouds of hundreds of thousands. Both are simulated by one shared step, so they behave the same in every runtime.

The editor provides presets: Fire, Smoke, Explosion, Sparkle, Rain, Snow.

PropertyDescription
emission_rateParticles per second
max_particlesMaximum alive particles
lifetimeParticle lifetime range (seconds)
speedInitial speed range
angleEmission angle range
color_start / color_endColor gradient over lifetime
size_start / size_endSize gradient over lifetime
gravity_modifierScales gravity on the particles
angular_velocitySpin speed
burst_countParticles per burst
activeEnable/disable emission
world_spaceEmit in world or local space
emit_shapePoint, circle, box, …
blend_modeAlpha, additive, …
color_curve / size_curveColour and size over lifetime, as curves
stretchStretch along the velocity
dragSlows each particle by e^(-drag t), frame-rate independent
turbulencestrength, scale, speed: swirls along the curl of world-anchored noise
collisionHit every non-sensor collider - kill or bounce
sub_emittersBurst another emitter, found by entity name, where a particle dies or hits

An emitter can name a shared definition instead of carrying every field:

"particle_emitter": { "particle_source": "particles/fire.particle", "z_order": 10 }

gpu_particles is a stateless cloud: each particle is a closed form of its index and the time, evaluated on the GPU, so the CPU cost is one uniform and one draw per emitter whatever the count. It sorts with sprites by z_order like everything else. Use it for snow, dust, star fields and spell storms; use particle_emitter when particles must collide or trigger sub-emitters.

-- Emit a burst of particles
Particles.emit_burst(entity, 20)
-- Enable/disable continuous emission
Particles.set_active(entity, true)
Particles.set_active(entity, false)
-- Change emission rate
Particles.set_rate(entity, 50)
-- Any emitter field, by name
Particles.set(entity, "drag", 1.5)
-- Get total alive particle count
local count = Particles.get_count()