Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone cocos2d中粒子系统的启动和停止_Iphone_Objective C_Ios_Cocos2d Iphone - Fatal编程技术网

Iphone cocos2d中粒子系统的启动和停止

Iphone cocos2d中粒子系统的启动和停止,iphone,objective-c,ios,cocos2d-iphone,Iphone,Objective C,Ios,Cocos2d Iphone,请,我想问一下我如何在iOS/cocos2d中启动一个粒子系统,让它运行一段时间,比如说10秒,然后让它停止 一个小的代码片段或例子,将作为一个指南将不胜感激 谢谢假设ps是您的粒子系统,您可以按如下方式启动和停止它: [ps resetSystem]; // starts, newly created effects are already running [ps stopSystem]; // stops 等待10秒可以按10秒的间隔安排选择器。假设ps是您的粒子系统,您可以按如下方式启

请,我想问一下我如何在iOS/cocos2d中启动一个粒子系统,让它运行一段时间,比如说10秒,然后让它停止

一个小的代码片段或例子,将作为一个指南将不胜感激


谢谢

假设ps是您的粒子系统,您可以按如下方式启动和停止它:

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

等待10秒可以按10秒的间隔安排选择器。

假设ps是您的粒子系统,您可以按如下方式启动和停止它:

[ps resetSystem]; // starts, newly created effects are already running
[ps stopSystem];  // stops
等待10秒可以安排一个选择器,间隔10秒。

希望它有帮助:

-(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];
}
希望有帮助:

-(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];
}