Search code examples
cocos2d-iphoneparticles

cocos2d particle system auto remove


As far as I understand, autoRemoveOnFinish only works only when the duration has a finite value. But what if I stop the particle system at some point, will it remove the node after no particles left? for example

CCParticleSun *particleSun = [CCParticleSun node];
particleSun.autoRemoveOnFinish = YES;
[self addChild: particleSun];

and at some point in the game I set

[particleSun stopSystem];

Will this remove the node after no particles left? Thank you in advance for helping.


Solution

  • The answer is yes.See the method -(void) update: (ccTime) dt in CCParticleSystem.m

        if( particleCount == 0 && autoRemoveOnFinish_ ) {
                    [self unscheduleUpdate];
                    [parent_ removeChild:self cleanup:YES];
                    return;
                }
    

    Try to set a breakpoint here to check,this will be called after no particles left.