Can the speed of a CCActionInterval be changed dynamically?

Can the speed of a CCActionInterval be changed dynamically?
0.0 0


I’ve seen many related questions but no definitive answer. If I have a sequence, or a CCDelayTime, or a CCMoveTo, or any CCActionInterval derivative, can I dynamically alter its speed somehow, as the action is running?

If I wrap any CCActionInterval with a CCSpeed and then tweak the speed variable, will this accomplish this task? Is this the accepted way to do it?


Yes. Note you need to execute the CCSpeed, not the inner action.


Hmm, well I just noticed that CCSpeed works on a CCActionInterval action, but a CCSequence is a CCFiniteTimeAction. Does this then mean that a CCSpeed can’t apply to a sequence?


You can try (just cast to CCActionInterval). I’ve tried casting CCSequence to CCActionInterval for using in Ease actions and it worked when sequence contained only interval actions.


And BTW you can use nested CCSequence::actionOneTwo’s to get CCActionInterval from it.


Hmm interesting, the idea of just doing a cast sounded scary to me, but when I look at the implementation of CCSequence::actions(), it’s just calling CCSequence::actionOneTwo multiple times to generate the result, which incidentally is always a CCActionInterval, which means it should be safe to do that cast always.

Thanks for pointing me in the right direction!