2013-04-10 17 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