I'm currently working on a card game. The game is a "loop" of functions that makes the computer player play, human play, and so on.
I can sum up like so :
function makePlayerPlay(player){
player.play();
nextPlayer();
}
function nextPlayer(){
// select the next player
makePlayerPlay(player);
}
As you guess, it's more than that. Many animations, other functions, etc.
I'm arriving at one point where I need to create a Pause button. I made a systeme that toggle a var.
var pause = true; // or false
My problem is :
when we pause the game, we can be into an ajax call, a jquery animation, etc. How can I pause everything, like if i launched was an alert popup ?
I know about the pause/resume jquery plugin. But animations, once it's resumed, don't stop at the right moment. (it's like a restart from 0) I also guess that i have to use timeout. But if so, shall i put timeout everywhere ? It's easy to stop a function, but to restart it from where is stopped, with the correct parameters ... I'm blocked :/
Thanks for any help