• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

HTML5 Game freezes after I lose the focus

Mert

Member
Hi.

I create some bullet objects whenever I receive a callback from a javascript extension, and keep doing that. These bullets are destroyed within seconds. However, when I lose the focus of the screen(like switching to another tab, or switching to another window) and return back to the game, all the creation order comes at once and freezes the game drastically! (for a while)

  1. A javascript extension sends an async event back to Game Maker.
  2. In the Social Async Event, Game Maker creates a bullet object.
  3. I use os_is_paused()==false to see if the focus is on, and then create the object.
What should I do?
 

TheouAegis

Member

Supposedly on Android the code is run and then cached. On other OS, the check only happens for one frame. So os_is_paused() would be false every step except that one step when you changed windows or tabs.

Have you tried window_has_focus()?
 

Mert

Member

Supposedly on Android the code is run and then cached. On other OS, the check only happens for one frame. So os_is_paused() would be false every step except that one step when you changed windows or tabs.

Have you tried window_has_focus()?
I have completely forgotten that functions existed, and it solved all my problems at once!
Thank you very much 💯 💯
 
Top