如何在cocos2d中停止runAction

时间:2013-04-10 05:49:30

标签: iphone ios cocos2d-iphone

如何在一段时间后停止游戏中的所有操作?

在下面的代码中我在sprite上调用runaction。

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

在这段代码中,精灵不断移动。如何在一段时间后或某些条件后停止上述动作?

2 个答案:

答案 0 :(得分:2)

runAction call Functionstop action sprite

[CCCallFuncN actionWithTarget:self selector:@selector(setInvisible:)];

- (void)setInvisiblestone:(CCNode *)node
{
    [target stopAllActions];
}

答案 1 :(得分:-1)

所有操作都停在方法中。

-(void)gameover
{
     [self unscheduleAllSelectors];
}