javascript - Added a pause function that wont work. Anyone know a solution? -
this question exact duplicate of:
i have added pause function game:
function pausegame() { if (!gamepaused) { game = cleartimeout(game); gamepaused = true; } else if (gamepaused) { game = settimeout(drawgame, speed - (level * 50)); gamepaused = false; } };
but reason, wont pause game. can figure out why wont work? game here.
you need set game
first time call settimeout()
. otherwise when cleartimeout(game)
, throws error (and doesn't set gamepaused
true
).