Open djminkus opened 8 years ago
If this proves tough to solve, we can simply end any one-player game where the tab loses focus, and re-generate the game state from another machine in multi-player games. If all players' tabs lose focus, the game can end.
The bitch of it is, Raphael depends on the browser (since it's creating SVG/VML DOM elements), so the client is necessary to host the game state.
Unless we find a way to run a mock browser on the server or something. Just throwing stuff out there at this point
Two birds, one stone.
Bird 1: "Pause" feature, which is considered a necessity in most games with single-player campaigns.
Bird 2: Bug: When the game tab loses focus (ex. window is minimized,) the animation rendering stops, leading to glitches when it regains focus.
Pausing script when tab/window loses focus: http://stackoverflow.com/questions/15871942/how-do-browsers-pause-change-javascript-when-tab-or-window-is-not-active
Clearing all timeouts: http://stackoverflow.com/questions/8860188/is-there-a-way-to-clear-all-time-outs
Stopping js execution: http://stackoverflow.com/questions/9298839/is-it-possible-to-stop-javascript-execution