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 ?
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.
@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.
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.
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).