0 votes

How would I get a game to pause when changing the current running app from godot to something else such as the home screen on the iphone? Is it also similar with andriod?

in Engine by (24 points)

1 Answer

+1 vote
Best answer

On any OS, you can use both NOTIFICATION_WM_FOCUS_IN and NOTIFICATION_WM_FOCUS_OUT.
Example:

func _notification(what):
    match what:
        MainLoop.NOTIFICATION_WM_FOCUS_OUT:
            pass # Pause the game
        MainLoop.NOTIFICATION_WM_FOCUS_IN:
            pass # Continue game

More info: Handling quit requests

by (616 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.