0
我寫了這段代碼。CCParticleSnow不循環/重複。
CCSpriteFrame *starParticleFrame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:spriteName];
CCParticleSnow *emitter = [[CCParticleSnow alloc] initWithTotalParticles:8];
[emitter setTexture:[starParticleFrame texture] withRect:[starParticleFrame rect]];
emitter.position = ADJUST_XY(theScreenSize.width/2, 3*theScreenSize.height/4);
emitter.scale = HD_PIXELS(1.5);
emitter.speed = 20 + arc4random() %20;
[emitter setDuration:kCCParticleDurationInfinity];
//[emitter setGravity:CGPointMake(0, -150)];
[self addChild: emitter z:-1];
它的工作原理。但問題是,它只是一次起火,而不是連續的。 (在這種情況下,只有8個粒子出來,就是這樣)。
但是,如果我交換的代碼的第2行到
CCParticleSnow *emitter = [CCParticleSnow node];
然後粒子系統能夠不斷循環。我閱讀了文檔並用Google搜索了這個 ,但無濟於事。最後一次嘗試是將該持續時間設置爲kCCParticleDurationInfinity。但仍然沒有工作。
請幫助我。
好吧有道理。我想我誤解了「initWithTotalParticle」。結束使用[CCParticleSnow節點],然後emitter.emissionRate = 5;得到我想要的東西。再次感謝Steffen。 :) – GeneCode 2013-02-23 01:05:11