Pausing game and timers :O
  • Hey i have problem with game pausing :C
    i have 2 timers in my game one count a game time and second add new enemy every 10 seconds.
    And i want to make game pause but when i do $.playground().pauseGame(); timers of course don`t stop.
    So my question: there is a possible to pause timers and resume it on resumeGame() method ?
  • selimselim
    Accepted Answer
    If instead of timer you register a callback with the .registerCallback() function it will automatically be "paused" at the same time as the rest of the game.


    If you do this and still want to keep the interval of 10ms you just have to make sure that the interval defined when specifying the playground is a multiple of ten, for example:
    $(“#someId”).playground({refreshRate: 60});


    The other way is to de-register the interval or to check for a flag in your function and only add the enemies when the flag is not set.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!