What Are Events

What Are Events

Top  Previous  Next

Events are essentially function pointers with some extra data.  They are used to dynamically update the particle system and its particles at run-time by allowing you to specify when a specific function should be called, and the order it should be called in relative to the other events.  Each time a particle system's Update() function is called the particle system checks to see if any events should fire (i.e. execute), and fires them if necessary.  Most events are typically setup before the particle system is ran, but they may also be added and removed at run-time. Additionally, you may also assign an event a group number, allowing multiple events belonging to the same group to be easily removed.

 

Every DPSF particle system has a property called ParticleEvents which keeps track of the particle system's particle events, and a property called ParticleSystemEvents which keeps track of the particle system events.  Particle events are events that are executed on the particle system's particles, and are used to update the particle's properties. Particle system events are events that executed on the particle system itself, allowing the particle system's properties to be updated.

 

An event holds a function pointer to the function that should execute when the event fires.  Particle event functions must follow the UpdateParticleDelegate prototype, which is:

 

       public void FunctionName(Particle cParticle, float fElapsedTimeInSeconds); where Particle is the particle class that the particle system is using for its particles.

 

Particle system event functions must follow the UpdateParticleSystemDelegate prototype, which is:

 

       public void FunctionName(float fElapsedTimeInSeconds);

 

So when you create new particle or particle system event functions, they must follow the above prototypes.  This is shown in each of the template files.  One thing to note however is that the functions do not necessarily have to be public; they can also be private, protected, or internal.