Emitters

From Slick2D Wiki
Revision as of 14:31, 8 August 2013 by Sigtau (Talk | contribs) (Created page with "[http://slick.ninjacave.com/javadoc/org/newdawn/slick/particles/ParticleEmitter.html ParticleEmitters] are added to a [http://slick.ninjacave.com/javadoc/org/newdawn/slick/par...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

ParticleEmitters are added to a ParticleSystem to control the production of particles and how they change over their life time. There are two key methods in the ParticlEmitter interface. First, we have update():

public void update(ParticleSystem system, int delta)

This method should be used to create particles. It's called every time particle system which the emitter belongs to is updated. The emitter is responsible for calling methods on ParticleSystem and the Particle class itself to create and configure particles for the effect the emitter is trying to achieve.

The second important method is updateParticle():

public void updateParticle(Particle particle, int delta)

This method is called every time the particle system is updated for every particle that was created as owned by the emitter (part of the particle creation parameters). The emitter is responsible for updating the particles based on the passing of their life. Often this method is left blank as it's possible to set a velocity on a particle which will take effect without any code in this update method.