Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / GetResumed()

Author
Message
Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 4th Sep 2022 18:22
Can anyone tell me, what I am missing here?

This code never worked;





So I'm using this code to detect if the app got resumed and it works fine but I do not feel it is the best way and want to use GetResumed() instead but never made it work




JosephB
18
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 4th Sep 2022 21:51
I am not sure about the timer parts of your code but reading the information on GetResumed() indicates that the game should be paused when this occurs. I have some code below that seems to work as follows:

Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 5th Sep 2022 16:10
Thank you @JosphB. My game levels has their time limits so I must keep track of 'minimized time' on android but never achieved that with the AppGameKit command GetResumed(), instead I made a simple solution which depends on a 250 milisecond of a delay limit, which is not so trusted and I am sure there must be a way with GetResumed().
JosephB
18
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 6th Sep 2022 01:31
It seems that even when the game has lost focus the Timer() function continues to advance, so there needs to be a way to identify, using Timer(), times when the game loses focus and when the game regains focus, then determine that difference and then subtract that from the total time since the game started. This seems to work with GetPaused(), but only works with Windows, so not helpful with mobile applications. Code as follows for Windows:

Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 6th Sep 2022 15:36
I suspect that he GetResumed() is only triggered after the sync() command thus the timers updates before we are able to control them. I mean may be.
Anyways, thanks a lot mate, keeping track of the time without GetResumed() works fine and you showed me that I don't miss anything.
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 7th Sep 2022 15:30
Application "Pausing" works differently on Mobile and Desktop.



Now run this on your Desktop and click off the back to the App (switch between focus of the App and IDE while both are visible).
You'll notice that Pause is ALWAYS Triggered when we switch away and Resume is ALWAYS Triggered when we switch back.

Now run it via Broadcast to your Mobile Device.
Pull up to switch to Task Manager and Tap back on the App.
Notice how ONLY the Resume ever Triggers... this is because while the Mobile App is Paused., it is quite literally Paused.
There is NO way to mimic this behaviour on Desktop... your App is ALWAYS running on your Desktop; so, you're using these commands to check if your App has Focus or Focus has disappeared.

As a note in this example., I'm not using Update( ); this ONLY applies to "Internal" Updates such-as the Sprite / Tween / Physics / etc... systems.
Still, what I am doing is checking BEFORE the Frame Update (i.e. Swap( ) / Sync( )); on Mobile you HAVE to do this else you'll never trigger them., where-as on Desktop they remain triggered until they're called to check or > 80ms between checks occur.
This is because on Mobile they're ONLY active for a Single Frame; and because the App is literally paused., well it has to be WITHIN the Frame it was paused on.

Hopefully this make sense and is useful.

Login to post a reply

Server time is: 2024-11-21 12:34:40
Your offset time is: 2024-11-21 12:34:40