0

这个函数什么都不做,大约 30 秒后 fps 开始下降。我想知道我必须做什么才能正确显示 ccparticle。

这是我的代码:

-(void) coccomilk:(CGPoint) p{

   CCParticleSystemQuad *milk = [[[CCParticleSystemQuad alloc] initWithTotalParticles:100 ] autorelease];

   milk.texture = [[CCTextureCache sharedTextureCache] addImage:@"milk.png"];
   milk.emitterMode = kCCParticleModeGravity;
   milk.totalParticles = 100;
   //milk.particleCount = 100;
   milk.life = 0.2f;
   milk.lifeVar = 0.1f;
   milk.startSize = 32;
   milk.startSizeVar = 32;
   milk.endSize = 2;
   milk.endSizeVar = 0;
   milk.angle = 90;
   milk.angleVar = 42;
   //milk.rotation = 0;
   //milk.rotatePerSecond = 0;
   //milk.rotatePerSecondVar = 0;
   milk.speed = 651;
   milk.speedVar= 335.5;
   milk.gravity = ccp(0,-2.72);
   //milk.blendAdditive = NO;
   milk.duration = 0.08;
   //milk.blendFunc = (ccBlendFunc) {GL_ONE,GL_DST_ALPHA} ;
   milk.emissionRate = milk.particleCount / milk.life;
   milk.radialAccel = 0;
   milk.radialAccelVar = 0;
   milk.tangentialAccel = 0;
   milk.tangentialAccelVar = 0;
   ccColor4F color = {1.0f,1.0f,1.0f,0.8f};
   milk.startColor = color;
   milk.startColorVar = (ccColor4F) {0.0f,0.0f,0.0f,0.0f};
   milk.endColor = color;
   milk.endColorVar = (ccColor4F) {0.0f,0.0f,0.0f,0.0f};
   milk.position = ccp(p.x,p.y);
   //milk.posVar = 0.0;
   milk.sourcePosition =  ccp(p.x,p.y);
   milk.visible = YES;

   [self addChild:milk z:2];

   milk.autoRemoveOnFinish = YES;
   [milk release];
   //[self performSelector:@selector(clearSprite:) withObject:water afterDelay:0.4];
}
4

2 回答 2

0

我建议你试试 ParticleDesigner,这是一个轻量级的应用程序,它允许以图形方式设计你需要的粒子,一旦你满意,就会生成 cocos2d 可以管理的配置文件。http://particledesigner.71squared.com/

于 2012-08-24T20:26:28.257 回答
0

还有更多错误:

  1. 发射率错误。你是从实际的粒子数来算的,初始化的时候是0。您的emissionRate 为0,这意味着不会发射任何粒子。正确的计算是:

    milk.emissionRate = milk.totalParticles / milk.life;
    
  2. 发布的太多了。它将在最后一个版本 (autoRemoveOnFinish) 上崩溃,因此请[milk release]从您的代码中删除最后一个版本。您的粒子系统将在其生命周期结束后释放 - 这就是 autoRemoveOnFinish 的用途 - 因此您无需手动执行此操作。

于 2012-08-25T06:34:46.930 回答