请问,我想问一下如何在iOS / cocos2d中启动一个粒子系统,让它运行一段时间,比如10秒,然后让它停止。
我们将非常感谢您提供一些代码片段或示例作为指南。
由于
答案 0 :(得分:7)
假设ps是你的粒子系统,你可以像这样开始和停止它:
[ps resetSystem]; // starts, newly created effects are already running
[ps stopSystem]; // stops
等待10秒钟可以安排选择器,间隔为10秒。
答案 1 :(得分: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];
}