control over individual particles in a CCParticleSystemQuad?

240 views Asked by At

I am calling setTexture:withRect: on a particle emitter... My question is, is there any way I can give multiple rects so that the particles can be comprised of random sprites? Or is the only way to accomplish this to use multiple emitters?

I thought if there was a way to actually get the collection of particles that are being generated, then I could loop over them and set their rect, or even color properties, but in the cocos2d docs, I see no way to get individual particle objects...... Is there any way to do this?

2

There are 2 answers

0
CodeSmile On

No, you can't access or modify individual particles.

If you want random sprites, simply run multiple particle systems with each using a different texture.

0
Kreiri On

If you want emitted particles to have different images, you can make sprite sheet of your particle images and subclass CCParticleSystemQuad overriding initTexCoordsWithRect: method so that instead of using same frame for very particle it uses different frames for different particles.

See here for example of such particle system using bitmap font. Using the same idea, I made CCParticleSystemQuad subclass which uses CCSpriteFrameCache to get frame information.