iOS applicationDidEnterBackground (and more)

Jason C.

Member
Hi Community

How do I code for iOS events such as, but not limited to:

- applicationWillResignActive
- applicationDidEnterBackground
- applicationWillEnterForeground
- applicationDidBecomeActive
- applicationWillTerminate

Obviously when a person is playing a game on an iOS device (or even Android), a phone call might come in, or the player might have to force the game to the background to perform other tasks, or they press the power/sleep button while putting their device down for the night, mid game.

Typically, an Objective-C/Swift application (including a SpriteKit game) will have these iOS events in a file called the AppDelegate, and we place the necessary code within these functions to handle how our game itself will handle these sorts of events, such as pausing and resuming, etc...

In GM2, how is this handled?
 

rIKmAN

Member
Typically, an Objective-C/Swift application (including a SpriteKit game) will have these iOS events in a file called the AppDelegate, and we place the necessary code within these functions to handle how our game itself will handle these sorts of events, such as pausing and resuming, etc...

In GM2, how is this handled?
You can use os_is_paused() to check if the game is paused either through the user closing the app, a phone call or other apps etc and run any necessary code before it gets cached as a background process.
Check the link to the documentation for the specifics.
 
Top