Currently in a test application I am building, I want to create particle bursts that appear when two objects collide. The main object will remain visible while the 2nd object will be removed. In the place of the 2nd object (that was removed) will be the particle burst. How should I set this up? Could you please guide me through the steps in creating this particle burst in cocos2d? Thank you!
Asked
Active
Viewed 979 times
1 Answers
1
http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:particles
heres the code i have for 3 emitters:
emitter = [[CCParticleGalaxy alloc] init];
emitter.texture = [[CCTextureCache sharedTextureCache] addImage:@"stars.png"];
emitter.startColor = ccc4FFromccc3B(ccRED);
emitter.endColor = ccc4FFromccc3B(ccGREEN);
emitter.life = 1;
emitter.duration = .5;
emitter2 = [[CCParticleGalaxy alloc] init];
emitter2.texture = [[CCTextureCache sharedTextureCache] addImage:@"stars.png"];
emitter2.startColor = ccc4FFromccc3B(ccRED);
emitter2.endColor = ccc4FFromccc3B(ccGREEN);
emitter2.life = 1;
emitter2.duration = .5;
emitter3 = [[CCParticleGalaxy alloc] init];
emitter3.texture = [[CCTextureCache sharedTextureCache] addImage:@"stars.png"];
emitter3.startColor = ccc4FFromccc3B(ccRED);
emitter3.endColor = ccc4FFromccc3B(ccGREEN);
emitter3.life = 1;
emitter3.duration = .5;
Defined as in .h
CCParticleGalaxy *emitter;
CCParticleGalaxy *emitter2;
CCParticleGalaxy *emitter3;
CCParticleGalaxy *emitter4;
then add it to your layer when needed and set the position
emitter.position = ccp(sprite.position.x, sprite.position.y);
[self addChild:emitter];
instead of CCParticleGalaxy
you can change that to CCParticleExplosion, CCParticleFire, CCParticleFireworks, CCParticleFire, ect...
just experiment and find whats best for you

mattblessed
- 772
- 1
- 12
- 27