Application "Pausing" works differently on Mobile and Desktop.
// Common
#Constant True -1
#Constant False 0
#Constant Enable 1
#Constant Disable 0
// Key Flags
#Constant KEY_ESCAPE 27
// App Globals
Global AppRunning As Integer : AppRunning = True
// Initialisation
SetSyncRate( 0, Enable )
SetWindowSize( 1280, 720, Disable )
SetVirtualResolution( 1280, 720 )
SetScissor( Disable, Disable, Disable, Disable )
SetWindowAllowResize( Enable )
UseNewDefaultFonts( Enable )
Global Paused As Integer
Global Resumed As Integer
// Main Loop
Repeat
Main( )
// Always allow EscapeKey to Exit
If GetRawKeyPressed( KEY_ESCAPE )
AppRunning = False
EndIf
Until AppRunning = False
// Main Function
Function Main( )
SetClearColor( 128, 128, 192 )
ClearScreen()
If GetPaused( )
Inc Paused
EndIf
If GetResumed( )
Inc Resumed
EndIf
Print( Paused )
Print( Resumed )
Render( )
Swap( )
EndFunction
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.