Pausing game when turning off
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Pausing game when turning off
Is there a way of pausing the game automatically whenever the player turns off the phone or when they press the home button?
Re: Pausing game when turning off
Does not Android pause apps automatically when putting them in the background (and background permission is not given)?
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Pausing game when turning off
I think it's this handler here, but do test if doing those things you mentioned will trigger a focus change:
https://love2d.org/wiki/love.focus
https://love2d.org/wiki/love.focus
Re: Pausing game when turning off
I'd assumed what dusoft said was true, but I just checked a random prototype I have on my Android phone and pressing the home button doesn't seem to pause the main loop. The callback RNavega mentioned should let you implement that yourself easily though.
Re: Pausing game when turning off
Good tip for anybody developing for Android (and possibly desktop as well - tabbing out of window pauses a game, tabbing back starts it again).
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Pausing game when turning off
Make dt small again!
If dt > 1/20 then dt = 1/20 end
If dt > 1/20 then dt = 1/20 end
Re: Pausing game when turning off
Interesting. You're saying that, if the game app happens to get suspended (actually paused) by the device, then the main loop (love.run) won't run, and so time will accumulate and when the game gets unpaused dt will have some huge delta time, say 10 minutes (600 seconds) or whatever time that the game was left paused for, which might mess something up in your game.
So you put a top cap on how big dt can be (1/20s = 0.050s = 50ms) to avoid that.
Re: Pausing game when turning off
I'm almost certain that didn't happen in my quick test. Things were collected and menu screens were opened while the app was in the background. If the delta was huge and it just caught up my game would have glitched badly as it doesn't handle large deltas.
Who is online
Users browsing this forum: No registered users and 1 guest