I am writing a checkers program. There is no need for a scheduler (no need to continuously keep time), but after some actions I want a delay. After the player moves I want a delay before the AI moves. If a piece can possibly double jump, I need to set a delay between when the first jump happens, and the second jump can occur, as the piece moves over time with animation.
For example: I have this code below that calls the move function.
if (move(currpiece, pos) == true)
{
//**I WANT TO PAUSE HERE
// now opponent moves
Position place;
GameBoard::piece* pp;
place = Game->getOppMove(pp);
while (move(pp,place) == false); //**ALSO NEED TO PAUSE HERE
}
The move function uses a Cocos action::
Action* moveToTargetPosition = MoveTo::create(piece_move_speed, posToLoc(pos));
sprite->runAction(moveToTargetPosition);
return Game->move(pce,pos);
in this example, I want to pause before the opponent piece moves. Also, if the AI can double jump, then the while loop calls two move functions with the same sprite (the second move function is called before the first action is finished), and there is an error.
How do I go about adding delaying my code until the move action is complete?
Thank you