Search code examples
cocos2d-iphonescrollparticles

Stars for scrolling shooter with CCParticleSystemQuad?


My code for init function:

NSArray *starsArray = [NSArray arrayWithObjects:@"Stars1.plist", @"Stars2.plist", @"Stars3.plist", nil];
    for(NSString *stars in starsArray) {
        CCParticleSystemQuad *starsEffect = [CCParticleSystemQuad particleWithFile:stars];
        [self addChild:starsEffect z:-1];
    }

The problem is that these particles appear and fully fill the screen rectangle during few seconds. But I need the sky full of stars from the beginning.


Solution

  • According to the answer at cocos2d starting particles from a specific time in the future , you can manually update the particle system. Example in cocos2d-x:

    CCParticleSystemQuad *particle = CCParticleSystemQuad::create("res/Particles/Stars1.plist");
    for (int i = 0; i < 10; ++i) {
        particle->update(.1);
    }
    

    You may need to change the interval to suit the particles.