How to center the window on start up?

Hi I’m following the hello hashlink tutorial here (Hello Hashlink - Heaps.io Game Engine).
However the window always starts in a strange location on the top left of the screen. How would I make it start centered?

Also is there a place where I can find all the “-D” settings that you can find in an HXML?

That’s weird. Actually it should by default always be in the center.
What is your OS? Maybe it’s not the same for Linux etc.? (I use Windows)
(if it is OS related and on Windows here’s a random thread I found, but propably won’t help)

You can also ask in the discord channel if you like (sometimes it seems few ppl use the forum :neutral_face: )

That’s true, we should actually add a proper page for the -D flags (used with Heaps). I think there’s no official information for that. I guess the community (we) need to collect them somewhere in a wiki page (page exists now and can be edited with a github account).

For me it always starts on the top left of the screen. I tested Deep nights new game Nuclear Blaze and it starts on the top left for me as well.
I’m using Windows 10 Home x64
NVidia GeForce RTX 2080 TI

PRISM+ PG400U PRO (Screen Size: 40", Resolution: 3440 x 1440, Refresh Rate: 144Hz)

The only thing that is maybe out of the ordinary are the number of monitors I have. It’s quite large and it’s not one of the common brands. I also have an uncommon 3 monitor setup.
MonitorBug.
The red rectangle is where my window appears. The blue monitor is my main monitor. The 4th monitor exists but it is turned off.

I asked on the discord as well and I got no response there -.-

1 Like

This is probably a bug in heaps, but here is a work around:
This will center your window on the current monitor on start up.

function centerWindow() {
	var window = hxd.Window.getInstance();
	var mIndex = window.currentMonitorIndex;
	var displaySettings = window.getCurrentDisplaySetting(mIndex);
	var xPos = Std.int(displaySettings.width * 0.5 - window.width * 0.5);
	var yPos = Std.int(displaySettings.height * 0.5 - window.height * 0.5);
	@:privateAccess hxd.Window.getInstance().window.setPosition(xPos, yPos);
}

override function init() {
    centerWindow();
}

Unfortunately it will flicker as it will start on the top left but this is probably a good workaround until the bug is fixed.

1 Like