Speed up / slow down every action

Speed up / slow down every action
0

Is there a convenient way to speed up / slow down every action by a factor?

For example, suppose I have these actions running:

sprite1.runAction(cc.moveBy(4, cc.winSize.width * 0.5, 0));
sprite2.runAction(cc.rotateBy(4, 360));

Both these actions take 4 seconds to complete. When I am 2 seconds into these actions I want to speed them up by a factor of 2 so the remaining animations take 1 second instead of 2 seconds. So total time taken will be 2 + 1 = 3 seconds.

Note:

  1. I want all the actions present in the game to speed up / slow down.
  2. I want all future invocations of actions to speed up / slow down too.

@pandamicro @zhangxm @ZippoLag @Zinitter

You could use

Speed

@mr746866

try cc.Scheduler setTimeScale
http://www.cocos2d-x.org/reference/html5-js/V3.8/symbols/cc.Scheduler.html#setTimeScale

2 Likes

@Zinitter Thank you for your help, much appreciated.

Interesting. I wonder if this can be set per-animation and not just globally for all running animations…

@ZippoLag

Do you mean sprite animation?
I think we need to subclass and override the update function in the animation and action.

Try read these post to get some ideas.


I need to increase the speed of cc.moveTo action for every click without stopping the action.

The only issue with setting this at the Director’s scheduler level, is that it will work across the entire system. If you want to be very specific, you will need to build a little deeper framework that involves several scheduler instances that can have control over different parts of the system with different flags etc. Note this probably won’t be a simple task, so if it does not matter, just set the timeScale of the Director’s scheduler.