[Android] Pause game when user click home button

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Mefihl
:warning: Old Version Published before Godot 3 was released.

How pause game in android platform when user click home button?

:bust_in_silhouette: Reply From: volzhs

Game will not running further when it goes background by pressing home button.
If you want to catch going background and show pause screen,
you can use this code

func _notification(what):
	if what == MainLoop.NOTIFICATION_WM_FOCUS_IN:
        # comes to foreground
        pass
	elif what == MainLoop.NOTIFICATION_WM_FOCUS_OUT:
        # goes to background
        pass

if you want to pause your game when goes to background,
see this document too.

http://docs.godotengine.org/en/latest/tutorials/engine/pausing_games.html

Game will not running further when it goes background by pressing home button

Test on few application made in godot and pure android and application in background (after home button press) use cpu by 1-5 %. In my application timer after back from background is incressed not freeze.

Mefihl | 2016-05-01 17:51

as my test project,
a player character walks to destination at touched point.
I pressed home button while a character is moving.

The character is positioned as same as before and still walking to destination,
when app is on foreground after a few second.

I’m not sure about Timer node.

volzhs | 2016-05-01 19:52