user1169079
user1169079

Reputation: 3083

Cocos2d-x - how to make wait second animation till one animation completes ?

I am making a card game where i want to draw card one by one. Card has to be deal one by one to player and then dealer respectively. During this procedure now I want to add animation of card which I have already done but it is happening together. Now I want to make one by one animation i.e. One card gets open then second card like that

I have tried using CCArray0>addobj(CCSequence)...method here is my code but its not working

m_AnimateCardArr = CCArray::create(4);

for (int i = 0; i < 4; i++) {

switch (i){

case 0: player->draw(card)
    cardAnimation(player,card,500,200);
    break;
case 1: player->draw(card)
    cardAnimation(player,card,550,200);
    break;
case 2: dealaer->draw(card)
    cardAnimation(player,card,500,1000);
    break;
case 3 :dealaer->draw(card)
    cardAnimation(player,card,550,1000);
    break;
}

++mCount;
}

    void CardAnimation(Player* player,Card* card, CCPoint startPts,CCPoint endPts){

        // ,, some code
     m_AnimateCardArr->addObject(CCSequence::create(spawn1,spawn2,finishAnimation,NULL));
     if(mCount>=4)
        card->runAction( CCSequence::create(m_AnimateCardArr));
}

As soon as mCount becomes 4 I try to run the action but its not working

Upvotes: 1

Views: 1715

Answers (1)

namnam
namnam

Reputation: 1

You can also use scheduler like this:

this->schedule(schedule(SEL_SCHEDULE selector), 2.0f);

SEL_SCHEDULE selector will be the function you need to call

2.0f is a timer for how many seconds you want to delay the call of the function

Upvotes: 0

Related Questions