How to make action animations timing right?

How to make action animations timing right?
0.0 0


short story is i have sprites i want to move down i use CCMoveTo action in a loop
the problem is that i can’t or didn’t found away to “wait” until the previews animation is finished .to start the next one.
the main problem is i dont know how many sprites will be , so i can’t use CCSequence with fixed number of action.

int GemsToRemoveHolderCount = GemsToRemoveHolder->count();

    for(int i=0;iobjectAtIndex(i);
            CCPoint posNew = gemNew->getGemPos();
            CCMoveTo *moveGemDownAction = CCMoveTo::create(0.3f,posNew);



There is a CCDelayTime action :


You can set delays, as mentioned, or on each step run sequence with your moveGemDownAction and call func with next step, so only after executing moveGemDownAction callback will executing and run next moveGemDownAction.

Some such that:
//class variables
int GemsToRemoveHolderCount = … ;
int count = 0;

void MyClass::callback()
if(count < GemsToRemoveHolderCount)
Gem* gemNew = (Gem**)GemsToRemoveHolder~~>objectAtIndex;
CCPoint posNew = gemNew~~>getGemPos;
CCMoveTo**moveGemDownAction = CCMoveTo::create(0.3f,posNew);
CCCallfunc::create(this, (SEL_CALLFUNC)&MyClass::callback)));
count++ ;
//somewhere in code call callback first time, and it will be animate your sprites GemsToRemoveHolderCount times.


well i wanted to avoid recursion , but it seams its the only way


There will be no recursion really. When you call runAction - you only say to cocos2dx main loop to process some action from next frame drawing. Your selector will be called from some cocos2dx method, not from MyClass::callback.


Thanks for your answer . i did it with recursion and its really looks and acts better