2012-08-24 39 views

回答

7

假設PS是你的粒子系統,你可以啓動和停止這樣的:

[ps resetSystem]; // starts, newly created effects are already running 
[ps stopSystem]; // stops 

等待10秒就能完成調度以10秒的間隔選擇。

1

希望它能幫助:)

-(void)addParticles 
{ 
    [particles resetSystem]; //restarts particles 
} 

-(void)playParticles //call this later somewhere in your code e.g in touches began [self playParticles]; 
{ 
    id playParticles = [CCCallFuncN actionWithTarget:self selector:@selector(addParticles)]; 
    id stopParticles = [CCCallFuncN actionWithTarget:self selector:@selector(stopParticles)]; 
    id wait = [CCActionInterval actionWithDuration:3]; 
    CCSequence *Particlesbegin = [CCSequence actions:wait,playParticles,wait,stopParticles, nil]; 
    [self runAction: Particlesbegin]; 
} 

-(void)stopParticles 
{ 
    [particles stopSystem]; 
} 



//in touches began 
if(CGRectContainsPoint(Btn.boundingBox, location)) 
{ 
    [self playParticles]; 
}