gpt4 book ai didi

iphone - 如何在 cocos2d 中停止预定的 runAction

转载 作者:行者123 更新时间:2023-12-01 17:26:21 24 4
gpt4 key购买 nike

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

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

最佳答案

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

[self unschedule:@selector(addTraget:)];

关于iphone - 如何在 cocos2d 中停止预定的 runAction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15921845/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com