1

I'm implementing a game on .

Now I implemented a "Replay of My Game" feature (Game shows from start)

But I want to replay my game at the speed of 1x , 2x , 3x , 4x. When changing speed to 2x all actions (move and rotate etc.) should work with respect to new changed variable.

How can I do that by changing the general speed of CCAction?

I want a general solution. I know the solution with variables or scheduler, but I want a general solution.

nvoigt
  • 75,013
  • 26
  • 93
  • 142

2 Answers2

2

You can use following code to slow or fast all scheduler and action:-

float val = 2.0; // to fast
val = 0.5; // to slow

Director->getInstance()->setTimeScale(val);

Default value is 1.0;

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • Is setTimeScale(val) function is a scheduler Function and val is the variable of time on which all the functions are running. If this is true then i had done this before. I want a solution in which all Actions e.g ( Flipping a card , rotation of cards , movement of cards , bouncing of cards and all such kinds of functions ) change there speed by changing the only one variable. – Muhammad Awais Qamar Oct 31 '16 at 07:20
1

Write a class like CCEaseIn by yourself.

Rewrite update(float time).

m_pInner->update(powf(time, m_fRate)); // this is what update() like in CCEaseIn

The code may be changed like this:

m_pInner->update(func(time)); 

func(float time) is the function to change the time. like time/2 which means to 0.5x, time*2 means 2x. You may save some param to make the function more adaptable.

ZeroZerg
  • 427
  • 3
  • 14