I'm making a HTML game with 'Egret', but when ever I switch to other tab, my game just pause automatically.
Is there any solution to prevent game pause?
I'm making a HTML game with 'Egret', but when ever I switch to other tab, my game just pause automatically.
Is there any solution to prevent game pause?
Most of the game's tick is based on the requestAnimationFrame. And this function is based on the browser's repaint. If you switch to another tab, the repaint is stop, so the requestAnimationFrame
stop.
If you really need your game run after switch to another tab, use the setInterval
as your game's tick with time 1000/60
.
But this is not so performance as the requestAnimationFrame.