我在菜单上有一个按钮作为CCMenuItemImage,我使用下面的代码进行动画增长和缩小,但是pauseSchedulerAndActions似乎不起作用。
id butActionGrow = [CCScaleTo actionWithDuration:0.8 scale:1.05];
id butActionShrink = [CCScaleTo actionWithDuration:0.8 scale:1.0];
id butActionSeq = [CCSequence actions:butActionGrow, butActionShrink, nil];
[myButton runAction:[CCRepeatForever actionWithAction:butActionSeq]];
[myButton pauseSchedulerAndActions]; //DOES NOT PAUSE ACTION
动画继续运行,不会暂停。对于它为什么不会暂停的任何想法?
由于
编辑:请注意,我需要能够在以后恢复操作。
编辑:基于Karthik Ra在下面的回答,我提出了以下解决方案,以便在需要时停止所有操作,然后在需要恢复操作时,只需检查以确保没有已经运行的操作并再次启动序列:[myButton runAction:[CCRepeatForever actionWithAction:[CCSequence actions:[CCScaleTo actionWithDuration:0.8 scale:1.05], [CCScaleTo actionWithDuration:0.8 scale:1.0], nil]]];
[myButton stopAllActions];
if ([myButton numberOfRunningActions] == 0) {
[myButton runAction:[CCRepeatForever actionWithAction:[CCSequence actions:[CCScaleTo actionWithDuration:0.8 scale:1.05], [CCScaleTo actionWithDuration:0.8 scale:1.0], nil]]];
}
答案 0 :(得分:1)
try this:
[myButton stopAllActions];