The whole idea of using the timer for gaming is not the best. The newer approach is using
. Please see:
Note the use of the fallback to
in the code sample.
The pausing of the game is pretty much trivial. You simply create some flag variable for paused/running state and don't process frames when the game is paused. You can see the complete code sample (sorry, it's not really minimal, is a fully-fledged game, but finding the technique is similar, please see
in the code), for example, here: Tetris on Canvas