|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
Tort |
Hey. How do I know that the game window is on top of other windows?
I need to pause the game when the game window is minimized or under another window.
1 Like
|
|
|
 |
Reply From: |
Jowan-Spooner |
Hey Tort,
by having a quick look at the documentation I found that OS has some nice properties called window_minimized and window_maximized. That’s the easier part. Being notified when the window leaves focus is a little more complex, though pretty logical. This is the solution I found on reddit.
Add this to any script. Should work.
func _notification(what):
match what:
MainLoop.NOTIFICATION_WM_FOCUS_OUT:
# the game window just lost focus from the operating system
pass
Detects minimizing, too. Of course there is NOTIFICATION_WM_FOCUS_IN too but you maybe don’t want to resume the game in the very moment the player opens the game again.
Hope it helps.
Btw want to make clear I didn’t know one of these ways either. Google did. :-]
Source:
~ Reddit - Dive into anything
~ OS — Godot Engine (3.1) documentation in English
Thanks, I found it. But unfortunately it does not work with a Steam overlay (shift+tab).
That might be more complicated, but there’s this cool plugin called GodotSteam. Here’s a link to its documentation. Maybe you will find something useful there.
Jowan-Spooner | 2019-05-10 19:08
1 Like