Attach emitter to every object in group

Is it possible to attach emitters to every object in a group?

Basically I have an enemy object that falls down hits the ground and spawns 5 physics objects called "groundPiece" and places them in a group called groundPieces.

I would like to loop through the group "groundPieces" and attach a particle emitter to each groundPiece.

But I can't figure out how to do it...

It's possible, though be careful not to have too many objects emitting particles at once or you'll kill framerate on devices. 5 emitters might be pushing it but if they're each only emitting a few particles at a time and the particles are set to die quickly it should be fine.

To get it to work you'll first need to define the particles and emitters before you actually need to use them. First, create 5 emitters using
CreateEmitter("name", x,y, rotation, visible, loop, autoDestroy)

Then, create particle type(s) using
CreateParticleType("particleName", PropertyTable)

Assign particle types to all 5 pre-defined emitters:
AttachParticleType("emitter", "particleName", emissionRate, duration, delay)

Then later, in the game loop where you spawn your 5 groundpieces, assign each of the emitters to follow them using
SetEmitterTarget("name", TargetHandle, autoRotate, rotationOffset)

You could probably store all of the emitters in a table and then assign them to each groundpiece in order of their index.

When you want the groundpieces to start actually emitting particles, trigger the emitters using
StartEmitter( "name", [oneShotEmission] )

This is just a summary of the Particle Candy commands you'll use. You should check out the docs on x-pressive's site as well as the samples to learn more specifically how to use them.

views:1309 update:2011/10/14 9:11:21
corona forums © 2003-2011