Hey
i have few sets of 2 Sprites each , i want for example:
- animate 3 sprites
- when all the animations done set sleep for 2 sec
- after sleep is done , animate another different 3 sprites
- when all the animations done set sleep for 2 sec
- after sleep is done , animate another different 3 sprites
- when all the animations done set sleep for 2 sec
- jump to 1
until somewhere in the game button pressed and the animation will stop
i tried 1 method
1 . recursion
` AllMatchedSymbol = m_pSymbolsVec.size(); // Hold array of sprites in each elm
animateMatchedRules(–AllMatchedSymbol); // call first time
void PayLinesManager::animateMatchedRules(int allMatchedSymbol)
{
if(allMatchedSymbol<0)
{
return;
}
int _allMatchedSymbol = allMatchedSymbol;
__Array* pMatchedSymbolArray = (__Array*)m_pSymbolsVec.at(allMatchedSymbol);
__String *key = (__String*)pMatchedSymbolArray->objectAtIndex(0);
// get the array of sprites to animate
__Array *MatchedSymbolArray = (__Array *)pMatchedSymbolArray->objectAtIndex(1);
for(ssize_t a=0; a<MatchedSymbolArray->count();a++)
{
auto actionBlink = Blink::create(2,10);
((Sprite*)MatchedSymbolArray->getObjectAtIndex(a))->runAction(actionBlink);
}
animateMatchedRules(--_allMatchedSymbol); // recursion call
}`
now this can work but i have 2 problems
- i cant do animation loop after the recursion done
- can’t add delay between calls
what do you think is the best way to implement this ?