0

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

Fenix Aoras
  • 221
  • 3
  • 10
  • See http://stackoverflow.com/questions/22080548/pausing-css-animation-with-javascript-and-also-jumping-to-a-specific-place-in-th/ , http://stackoverflow.com/questions/30712525/stop-css-rotate-animation-smoothly-on-unknown-keyframe/ – guest271314 Nov 18 '15 at 17:54
  • See also http://stackoverflow.com/questions/28079758/pattern-for-interrupting-heavy-computation-on-browser-event – guest271314 Nov 18 '15 at 18:07

0 Answers0