Question

My question is for apps written in cocos2d v1.1.0-beta2b for ios:

What are the best practices for removing/releasing a CCParticleSystem?

One way I know of is using setAutoRemoveOnFinish:YES.

[emitter setAutoRemoveOnFinish:YES];
[emitter stopSystem];

Another way is removing the emitter manually using removeChild.

Are there any others? Which way is usually recommended?

As a side note, are there any known issues regarding CCParticleSystem removal/release under cocos2d v1.1.0-beta2b?

Was it helpful?

Solution

To remove a particle system, just remove it from its parent node. It's the best way.

If your particle system doesn't have a infinite duration, the best way is use setAutoRemoveOnFinish. It will automatically remove the system from parent node when particle system ends.

If your particle system have a infinite duration, then use removeChild with cleanUp:YES (you dont need to set stopSystem before). This way the system is removed forced.

Or you can use stopSystem with setAutoRemoveOnFinish:YES, and the system will be removed after the last particle ends. This way the system is removed smoothly.

Other tips:

  • Use CCParticleSystemQuad instead of CCParticleSystem.
  • Is recommended that you create your particle system using an autorelease constructor, like [CCParticleSystemQuad particleWithFile:] or [CCParticleSystemQuad particleWithTotalParticles:].
  • And, of course, use release if you have a property retaining it.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top