目前在我正在构建的测试应用程序中,我想创建两个物体碰撞时出现的粒子爆发。主要对象将保持可见,而第二个对象将被移除。代替第二个对象(已移除)将是粒子爆发。我应该如何设置?你能指导我完成在 cocos2d 中创建这个粒子爆发的步骤吗?谢谢!
问问题
976 次
1 回答
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
于 2012-03-27T20:18:58.590 回答