0
CCAnimation *anim = [CCAnimation animationWithSpriteFrames:animFrames delay:reloadSpeed]; 
CCFiniteTimeAction *animFinite = [CCAnimate actionWithAnimation:anim];
CCRepeat *repeatAction = [CCRepeat actionWithAction:animFinite times:1];
id animDone = [CCCallFuncN actionWithTarget:self selector:@selector(doneAnimatingOnce)];
[self.person runAction:[CCSequence actions:repeatAction, animDone, nil]];

上面的代码永远不会到达函数“doneAnimatingOnce”,但下面的代码会,所以我觉得finiteTimeAction有问题

//CCFiniteTimeAction *animFinite = [CCAnimate actionWithAnimation:anim];
//CCRepeat *repeatAction = [CCRepeat actionWithAction:animFinite times:1];
id animDone = [CCCallFuncN actionWithTarget:self selector:@selector(doneAnimatingOnce)];
[self.person runAction:[CCSequence actions:animDone, nil]];

我想做的就是运行一次精灵表动画,但我已经为此苦苦挣扎了大约 4 个小时,有人可以帮忙吗?

CCFiniteTimeAction *animFinite = [CCAnimate actionWithAnimation:anim];
    id animDone = [CCCallFunc actionWithTarget:self selector:@selector(doneAnimatingOnce)];
    [self.person runAction:[CCSequence actionOne:animFinite two:animDone]];

运行动画但该函数仍然从未被调用

4

1 回答 1

0

如果您希望动画运行一次,则不需要任何CCRepeat操作。试试这样的东西。-

CCAnimation *anim = [CCAnimation animationWithSpriteFrames:animFrames delay:reloadSpeed]; 
CCFiniteTimeAction *animFinite = [CCAnimate actionWithAnimation:anim];
CCCallFunc *animDone = [CCCallFunc actionWithTarget:self selector:@selector(doneAnimatingOnce)];
[self.person runAction:[CCSequence actionOne:animFinite two:animDone]];
于 2013-08-24T15:17:49.677 回答