Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Gameframe

Custom window frame for GameMaker games · By YellowAfterlife

Can't Set Window Position With Code

A topic by EpochGD created 13 days ago Views: 51 Replies: 5
Viewing posts 1 to 5

If I try to move the window relative to its own position using window_set_position(), it bumps the inside of the window far down and right. Even if I literally set the window position to itself:
window_set_position(window_get_x(),window_get_y())
it moves the inside of the window far down and far right. Same with window_set_rectangle. For some reason it doesn't like to be moved with code. Is this something that only exists in the demo?

Developer (1 edit)

Gameframe does not modify those built-in functions, so you should start with testing whether they work as intended in an empty GameMaker project (without Gameframe) that has the “borderless window” option enabled. Sometimes things break with GM updates

Ok, so this behavior is extremely peculiar after testing it out.

In Gamemaker, you can modify a borderless window's position no problem. But if "obj_test" is spawned, or if you go to a room with "obj_test", the ability to modify the window's position gets messed up, and will bump very far if you try to modify it, even after restarting the game.

I bound the R key to restart the game AND reset the position of the window:

game_restart();
window_set_position((display_get_width()*0.5)-(window_get_width()*0.5),(display_get_height()*0.5)-(window_get_height()*0.5));

And I bound the Enter key to spawn "obj_test."

It works just fine when "obj_test" is not present. But even if you restart the game, so it doesn't exist anymore, it will only reset the inside of the window to the middle of the original window. (see video)

If you try to spawn "obj_test" after the window has been weirdly offset, it looks like it tries to create the new window at the middle of the original window, and then it crashes.

Developer

Hm, so I imported the gameframe test project into the same GM version as you’re using, and it seems to work normally, including with this

if (keyboard_check(vk_space)) {
	window_set_position(window_get_x(),window_get_y())
	show_debug_message("re-positioned!");
}

If you can send me an email, I can send you a YYZ and you can see if you can get it to misbehave

Generally makes me think that you have something else going on that causes this weird interaction.

(3 edits)

It is very possible I'm just doing something weird. I'll shoot an email your way.

Also, I just pasted the code you posted into the demo I originally had, it still does the same weird repositioning.

Developer

If anyone’s wondering, the problem was that the author mixed up Window Freeze Fix (the test project of which is called window_frame) and Gameframe, and I guess Window Freeze Fix is even less stable in latest GameMaker than it was before.