How do I make a window go below the center of the screen?

Godot Version

4.7.1

Question

I’m trying to make a window go below the center but I can’t do it, how do I do it?

Do you mean the game’s own OS window, or a Window node inside your game? And by below the center, do you mean lower down the screen than center, or behind whatever is sitting in the center?

If it’s the game window and you want it lower than center, you can center it and then add an offset:

var screen := DisplayServer.window_get_current_screen()
var screen_pos := DisplayServer.screen_get_position(screen)
var screen_size := DisplayServer.screen_get_size(screen)
var win_size := DisplayServer.window_get_size()
var offset := 200

DisplayServer.window_set_position(screen_pos + (screen_size - win_size) / 2 + Vector2i(0, offset))

The screen_get_position part is there for multiple monitors, without it the position ends up relative to the primary screen.

I mean a Window node in my game.

Ah ok, for a Window node you can use move_to_center and then push it down from there:

$MyWindow.move_to_center()
$MyWindow.position.y += 200

If you’re bringing it up with popup_centered, same idea, call that first and add the offset after it’s on screen.

Thanks!