1

我正在使用下面的代码添加每 1.5 秒后创建的精灵,如下所示

[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 方法已安排,那么在满足条件一段时间后如何停止此预定操作?

4

2 回答 2

4
[self unscheduleAllSelectors]; //For all selectors

或者,

[self unschedule:@selector(YOURSELECTOR)]; //For specific selector
于 2013-04-10T09:36:42.907 回答
4

只有取消调度特定的调度程序然后使用这个:

[self unschedule:@selector(addTraget:)];
于 2013-04-10T09:48:58.977 回答