This project is read-only.

Particle system toggles

Jul 18, 2011 at 9:39 PM


I've started using Xen's particle system and it works wonderfully. Now I'm trying to make a rocket exhaust by using a toggle trigger. But, when i tried to create a toggle trigger the content importer crashes and I receive the error "Index was outside the bounds of the array.". I modified the Fire.particles file from the tutorial.

This is my XML:

<?xml version ="1.0" encoding ="utf-8" standalone ="yes"?>
<particlesystem xmlns:xsi="" 

		This particle system is here to look pretty
		It's not intended to teach anything specific.
		For more detailed explaination of the particle system format, see Tutorial 21, and Fireworks.particles
	<system frame_rate="60hz">
      <toggle name="rocketExhaust">
        <emit type="spark" life="1" life_variance="0.2" />
	<particle name="spark" blend="additive_saturate" texture="fire.png">
        <set target="alpha" arg0="1"/>
        <div target="local0" arg0="life" arg1="delta_time"/>
        <sub target="alpha" arg0="local0"/>

Please help!!!


Jul 18, 2011 at 11:15 PM
Edited Jul 18, 2011 at 11:16 PM

Hi. Yes, this is a bug.

When the particle system is processed, it runs a simulation on the system to see how many particles it will create. Unfortunately, there is a typo in the code that runs the simulation.
If you open the file:


On line 1260 change (make sure to get the right line!):

ParticleSystemEmitterLogic data = parent.SystemData.Triggers[index];


ParticleSystemEmitterLogic data = parent.SystemData.ToggleTriggers[index];

Run the build again to update the processor.

Toggles aren't needed very often, and my test case for them uses both triggers and toggles - so it didn't catch this crash.

In your case, I imagine a standard Trigger would be more suitable for a rocket (almost any temporary effect is likely going to work better with a Trigger).
If you setup your trigger to generate a smoke puff / sparks, etc for a single frame, then fire the trigger every frame the rocket is alive (with the position set to the rocket position).

The has two advantages: Only one Toggle can exist at once whereas you can specify how many instance of a Triggers to keep in memory with the 'allocation_multiplier'. So for a rocket trail, this might be (say) 64. Then at no point will there be more than 64 puffs of smoke active at any one time. Secondly, toggles need to be turned on and off - whereas a trigger is fire and forget. Also, you will likely need to use the 'gpu_buffer_position' flag for your system. Keep it in mind :-)


Jul 19, 2011 at 8:45 AM


Thx for the answer and the advice. I thought about doing it the same way you proposed (with a trigger), but i was concerned about having more than 1 particle system instance.

My idea was to reuse the same particle system for each rocket on screen. I think it will be more performance efficient, if you have, let's say, 20 rockets on the screen.  

Jan 16, 2013 at 11:12 PM
Edited Jan 16, 2013 at 11:12 PM

Important note: do not forget to change also the line 1134.

Summing up, on file "xen\src\Xen.Ex\Graphics\ParticleSystemContent.cs" change:

> Ln. 1134, to:

get { return parent.SystemData.ToggleTriggers[index].Name; }

> Ln. 1260, to:

ParticleSystemEmitterLogic data = parent.SystemData.ToggleTriggers[index];


Kind regards