2013-04-10 109 views
1

我使用下面的代码添加将每1.5秒之后创建的精灵如下如何停止预定runAction在cocos2d

[self schedule:@selector(addTraget:) interval:1.5]; 

-(void)addTraget:(ccTime)dt{ 
CCSprite *target = [CCSprite spriteWithFile:@"img1.png" rect:CGRectMake(0, 0, 80, 36)]; 

target.position = ccp(-target.contentSize.width/2, 100); 
[self addChild:target]; 
target.tag = 1; 

id actionMove = [CCMoveTo actionWithDuration:actualDuration*2.5 position:ccp(winSize.width + (target.contentSize.width/2), actualY)]; 
id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)]; 
id sequece = [CCSequence actions:delayTime1, calFun1, delayTime2, calFun2,actionMove, actionMoveDone, nil]; 
id repeate = [CCRepeatForever actionWithAction:sequece]; 

[target runAction:repeate]; 
} 

的addTarget方法定那么如何后停止这个计划行动满足条件后的一段时间?

+0

您使用以下代码的时间表。重复选项有 [self schedule:@selector(addTraget :) :) interval:1.5 repeat:NO delay:NO]; – Nims 2013-04-10 09:28:27

+0

亲爱的我想重复1分钟或满足条件之前...我通过[self unscheduleAllSelectors]得到了解决方案; – KsK 2013-04-10 09:32:26

回答

4

只有取消调度特定调度然后使用此:

[self unschedule:@selector(addTraget:)]; 
4
[self unscheduleAllSelectors]; //For all selectors 

,或者

[self unschedule:@selector(YOURSELECTOR)]; //For specific selector