I am making a multiplayer card game for Facebook instant Games Platform ,
and i have noticed that when i change the browser tab to another tab my game freezes , unlike other games i’ve seen (the game keeps working even if you minimize/change browser tab )
Example : UNO game (Facebook instant game).
My question is how i can achieve that because , my game is multiplayer turnbased and when the game put in background i cannot keep tracking the player time , i want the game to keeps playing even if it have been set to background .
PS : after looking into other game with playing in background capability it turns out that they are made using LayaBox .
You can set the frame rate with something between 30 and 60 (exclude), then we will use setTimeout to simulate the main loop, then it can still be running in background. But don’t rely on it, browsers have total control on it and don’t like JavaScript running in background
Thank you for you help !
it would be much appreciated if you give me more details ,
I have set the game frame rate to 35 using game.setFrameRate(35); and it is still blocked when i change the browser tab .
Thanks to @pandamicro , i was able to run the game in the background In WEB , but what about the NATIVE builds , i am willing to launch an android version too , and i couldn’t find a way to do the same as i did in the web version .
Please can you guide me to which part in the native source code i should change to make the game work in background in android too (if that is an option obviously).
Thank you for you support !!!
@pandamicro I’ve noticed also that by default game is paused but for example running Spine animations are NOT paused, which can cause unwanted behaviors. If possible it would be nice to pause third party stuff like spine as well by default