1

I'm trying to use the particle system of Cocos2d, to add effects to an existing scene inheriting from CCScene on my iPad. However, somehow the particle system is not added to the stage/running. I'm not able to get it running after searching multiple sites including here.

-(CCParticleSystem*)createEmitter
{
    CCParticleSystem *emitter = [[[CCParticleSystem alloc] initWithTotalParticles:50] autorelease];
    [emitter setAutoRemoveOnFinish:YES];
    [emitter setEmitterMode:kCCParticleModeRadius];
    [emitter setTexture:[[CCTextureCache sharedTextureCache] addImage: @"cloud_small.png"]];
    [emitter setStartColor:ccc4f(1, 1, 1, 1)];
    [emitter setEndColor:ccc4f(1, 1, 1, 1)];
    [emitter setStartRadius:10];
    [emitter setEndRadius:250];
    [emitter setStartSize:100];
    [emitter setEndSize:50];
    emitter.life = 1;
    emitter.duration = -1;
    emitter.position = ccp(0,0);
    
    return emitter;
}

and called with:

[self addChild:[self createEmitter]];

I have worked with the CCParticleExplosion class, in which I managed to get it to work.

-edit-

I have found a solution, which gives me the correct result. But to my opinion this is not the way it is intended to work.

I have replaced the CCParticleSystem with CCParticleFire and now works fine. Since CCParticleFire is a particle example, I find this solution a "way around things".

-(CCParticleFire*)createParticleEffect
{
    CCParticleFire *emitter = [[CCParticleFire alloc] initWithTotalParticles:50];
    [emitter setEmitterMode:kCCParticleModeRadius];
    [emitter setTexture:[[CCTextureCache sharedTextureCache] addImage: @"cloud_small.png"]];
    [emitter setStartColor:ccc4f(0.1, 0.1, 0.1, 0.5)];
    [emitter setStartColorVar:ccc4f(0.2, 0.2, 0.2, 0.3)];
    [emitter setStartRadius:10];
    [emitter setStartRadiusVar:20];
    [emitter setEndRadius:200];
    [emitter setEndRadiusVar:20];
    [emitter setStartSize:100];
    [emitter setStartSizeVar:30];
    [emitter setEndSize:50];
    [emitter setEndSizeVar:15];
    emitter.angle = 90;
    emitter.angleVar = 360;
    emitter.life = 1;
    emitter.lifeVar = 2;
    emitter.duration = -1;
    emitter.position = ccp(75,75);
    emitter.emissionRate = 10;

    [emitter resetSystem];
    return emitter;
}

1 Answers1

0

check this position emitter.position = ccp(500,500); on iPhone, this position will be Off-Screen and you won't be able to see anything.

Saurabh Passolia
  • 8,099
  • 1
  • 26
  • 41