Topic was automatically imported from the old Question2Answer platform.
Asked By
user41420082
Old Version
Published before Godot 3 was released.
I have a script for centering the game window and I put it on the _ready() function. However, it doesn’t fire fast enough and as an end result, the game window opens at the top left of the screen and pops to the center. Is there a way to make it start at the center immediately?
var screen_size = OS.get_screen_size()
var window_size = OS.get_window_size()
OS.set_window_position(screen_size*0.5 - window_size*0.5)
you can center the game window from the “Editor Setting” which are available under the “Settings” button in the editor. From where you have the option “Game Window Placement” where you can define where the game window should appear(“Rect” option). Hope that helps you
Hi, this doesn’t work. it does the same thing as my script. The game window pops up at the top left for a brief moment and then pops back to the center. I want the game to open in the center immediately.
Not to mention, doesn’t work on my compiled game whereas my script does.
user41420082 | 2016-07-23 13:35
Okay sorry I actually only tested this with the godot 2.1 beta and not with the 2.04. Seems they changed that with version 2.1 because in this version it’s immediatly in the center. But in that version it also doesn’t affect an exported game like your already mentiond(at least for me), so I’m also clueless at the moment, sorry