Slow motion effect

Hello

I want to implement a slow motion effect for some of the enemies (CCSprite) I have on my game.
I understand that there is a method setTimeScale that could do this, but unfortunately it modifies the speed on all the sprites that I have in my game.
Is there a way of slowing the actions for just some of the sprites ?

Thanks!
Adrian

CCMoveTo::initWithDuration( duration, point );
input the same destination point with a longer duration, which will case the sprite moves more slowly.
Is it the effect you want?

I don’t have just MoveTo actions, each enemy has a different action, and when I use this power up ( the slow motion ) each of them are in the middle of their own animations / actions.

Hi Check out my latest post, i have made a advanced sprite class with frame rate setting. But its only for sprite frame animation. Not for move/rotate etc type of actions.

Are you also planning to do it for move / rotate ?
I don’t have frame animations on my game, only move actions.
Thanks!

@Adi Fly
Varadharaj’s suggestion is right for you.
You can read the source in CCActionInterval.cpp CCMoveTo::update(ccTime). Actions are controlled by their update method.
So regarding you requirement, the simplest way is to create an global variable, use it to affect each CCActionInterval::update methods. You had to hack the code in CCMoveTo::update, CCRotateTo::update and so on.
If you don’t like to hack the engine, the other way is to learn Varadharaj’s design in AdvanceSprite: override your own update method.

Thanks, I will try your suggestions.

Do you think this would be a nice feature for cocos2d-x ?
I think that a lot of developers want to put this kind of effects ( slow motion, fast forward ) in their games.

Thanks again!

Maybe make a derived custom class that inherits what you want to slow-mo, and override the tick function and pass down a proportion of the original tick value? Or maybe there’s some nasty global singleton that’s managing everything and you cant do this…

Maybe make a derived custom class that inherits what you want to slow-mo, and override the tick function and pass down a proportion of the original tick value? Or maybe there’s some nasty global singleton that’s managing everything and you cant do this…

Sorry to dig this thread up again, I just want to do the same but not sure whether back a year ago cocos framework is capable to do as simply as the following (thanks to this tweet https://twitter.com/rizergames/status/41204788003749888).

I adapted it to adhere to cocos2d-x v.2.0.3.

CCDirector::sharedDirector()->getScheduler()->setTimeScale(0.2);

Use value more than 1 to “fast forward”
Use value less than 1 (but not below 0) to “slow motion”
Use value 1 for normal speed.

2 Likes