Types of Events
|Top Previous Next|
There are four types of events: Every Time Events, One Time Events, Timed Events, and Normalized Timed Events.
Every Time Events are events that fire every time the particle system's Update() function is called, and they persist until they are explicitly removed. Every time events are executed on every active particle in the particle system. Examples of events that you would want as every time events are things like updating a particle's position according to its velocity, or interpolating between a particle's start and end colors.
One Time Events are events that fire once as soon as they are added, and then they are automatically removed and will never fire again. One time events are executed on every active particle in the particle system. Examples of events that you would want as one time events would be things such as changing to particle's velocity when the user presses a button, or making the particle system react to some other game event.
Timed Events are events that are set to fire at a specific time. Both particle systems and particles have an ElapsedTime property which tells how long the particle or particle system has existed for. While the particle's ElapsedTime property is available with the rest of the particle's properties, the particle system's ElapsedTime property can be found in the ParticleSystemEvents.LifetimeData property. So if you want an event to fire after the particle system has existed for 5 seconds, you could create a timed event with a TimeToFire of 5.0 to accomplish this. Timed particle events are only executed on the particles that have just reached the specified TimeToFire, and they only fire once.
Normalized Timed Events are similar to timed events, except that instead of using the ElapsedTime property, they use the NormalizedElapsedTime property which is always between 0.0 and 1.0. The NormalizedElapsedTime property is calculated by the equation ElapsedTime / Lifetime, where the Lifetime is the amount of time the particle or particle system is set to exist for. So if you want an event to fire halfway through a particle's Lifetime, creating a normalized timed event with a TimeToFire of 0.5 would accomplish this.