巨人の殺人者
巨人の殺人者

Reputation: 21

GML When resolution is not in fullscreen and you swap resolutions, the game is not centered on the screen

I have settings screen within my game for resolution. Within this setting page, you have a fullscreen ON and OFF option. I also have a resolution switcher above it. However when you turn fullscreen off and change the resolution. The game is no longer centered on the screen and moves around as you change the resolution. I have tried many things such as window_center() within the switch statement. However this isnt solving my issue. Does anyone have any ideas on how to keep the game centered on the screen when changing resolutions with fullscreen turned off? (Such as a windowed fullscreen)

Upvotes: 0

Views: 545

Answers (1)

YellowAfterlife
YellowAfterlife

Reputation: 3202

You'll want to either delay window_center call by 1 frame (as the window position data doesn't update till the end of the frame), or use window_set_rectangle to calculate position yourself immediately, like so

window_set_rectangle((display_get_width() - width) div 2, (display_get_height() - height) div 2, width, height);

(or slightly more complex if you want to resize window relative to the current position)

Upvotes: 2

Related Questions