Question

I wrote this code.

 CCSpriteFrame *starParticleFrame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:spriteName];
            CCParticleSnow *emitter = [[CCParticleSnow alloc] initWithTotalParticles:8];

            [emitter setTexture:[starParticleFrame texture] withRect:[starParticleFrame rect]];
            emitter.position = ADJUST_XY(theScreenSize.width/2, 3*theScreenSize.height/4);
            emitter.scale = HD_PIXELS(1.5);

            emitter.speed = 20 + arc4random() %20;
            [emitter setDuration:kCCParticleDurationInfinity];

            //[emitter setGravity:CGPointMake(0, -150)];
            [self addChild: emitter z:-1];

It works. But problem is it just fire up the snow once, and not continuous. (in this case, just 8 particles came out and that's it).

However, if I exchange the 2nd line of code into

CCParticleSnow *emitter = [CCParticleSnow node];

then the particle system able to loop continuously. I read the docs and googled about this but to no avail. The last try was to put that duration to kCCParticleDurationInfinity. But still not working.

Help me, please.

Was it helpful?

Solution

You limit the emitter to 8 particles. It will only spawn new particles after the initial 8 are gone.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top