I have three action each work individually fine…
CCAnimate animateAction = CCAnimate::actionWithAnimation;//Fine
CCRepeatForeverrepeatAction = CCRepeatForever::actionWithAction(animateAction);//Fine
CCFiniteTimeAction *catMove1 = CCMoveTo::actionWithDuration((ccTime) actualT, ccp(windowSize.width/4, actualY));//Fine
testSprite~~>runAction); //Working fine
testSprite~~>runAction(CCSequence::actions(catMove1, repeatAction , NULL)); //It’s Not Working, only cat move done not animate
So, Is there any issue or we cannot use CCRepeatForever action in CCSequence??
If No, then how I fullfill my requirement??
In fact what I meat is another issue:
In the real world, we always want to repeat a sequnce of actions.
But we can’t add a CCSequenceAction into CCRepeatForever, since CCSequenceAction::actions() and CCSequenceAction::actionsWithArray() return CCFiniteTimeAction**, but CCRepeatForever needs CCActionInterval**。
I used CCRepeatForever action in last argument of CCSequence, then no any other coming action would block. But it also not working.
Can you suggest me, how I resolve my problem.
My requirement is that I have to move a sprite from one point to other with animate action, but my animate action stopped in the middle of movement…I want to animate it untill it not reached on destination point? CCSPawn is also not working?/
These are the rules regarding repeatforever and sequences acctions:
CCRepeatforever CAN contain CCSequence actions
CCSequences CAN’T contain CCRepeatforever actions (well… they can, but they wouldn’t execute it!)
So the solution for this problem that I’ve found is to implement the repeat actions inside a block, and make the sequence actions to call (in the last place in order to be consistent with a repeat forever ongoing action…) the block with the actions:
Create a CCCallBlock action (using C++11.0 lambdas):
Implement your repeat forever actions inside a Block (Closure, Blocks, Lambdas… you name it)
Notice how inside the block the CCRepeatforever actions is made out of a CCSequence (Rule number 1 complaiant)
Notice how inside the CCSequence definition a Block is called, which is defined in our code.
Depending on what you’re doing you might just get away with using Repeat, instead of RepeatForever. I’m only using this to repeat some arrow scaling as part of a tutorial, so I don’t care if it stops repeating after 9999999 repeats. Repeat doesn’t block anything and works exactly as you expect.
As for RepeatForever, not being able to repeat a sequence seems like its a bug, no matter what the explanation is as to why its not working. Cocos2d-x is still super awesome