A few things to note;
- Don't use surface_resize in a step event. Its a pretty intensive function and will slow down your game a lot - you should only have to use it once the settings change.
- room_set_view changes it for the room "object", not the current instance.
- You shouldn't change the room size based on the resolution settings. Your room is basically the definition of the level - resizing the room will create space on the right and bottom side while the level itself will stick to the left top side. It would look weird.
Short answer: The way to fix your code is to use the *current*, *active* room settings. The room_set_view will change the properties of the room, not the current "loaded" settings of the room. You can use those functions to change properties of a room, before going in to it.
If you want to change the
current room settings, you should change the variables room_width, room_height and view_*.
Still, its bad practice to change the room size. You should use views, and adapt that based on the resolution settings.
If the game is dependant on a specific view size (e.g., you shouldn't be able to look wider than the view), you should not change the view size. You can change the surface size, and scaled down sprites / backgrounds will be scaled up to fit the view (so if you have a 0.5 scaled sprite on 1280x720, it will look like 0.75 on 1920x1080 - so it won't be pixelly but it will actually look good).
The way I do it, is that I store the "resolution" settings in an INI. On game start, the settings load, and everything is ran like the code above. If someone changes the settings in a settings menu, you re-run the "setupDisplay" script again.
Now, to fix your specific problem the hard way:
1) Enable views in the room. Setup the view exactly as you'd want the game to be. I'm guessing your room is 640x360 and you're always showing the entire room on the screen - even now you should enable the use of a view.
2) Make a script, call it something like "setupResolution"
3) In this script, use the following functions;
Code:
surface_resize(); //To resize the surface that the game is rendered on
window_fullscreen(); //To set the game fullscreen or not, based on the preference
window_set_size(); // To set the window size (maybe someone wants 640x360 windowed, or maybe 1280x720 windowed?
texture_set_interpolation(); //If you're doing a pixel-art ish game, don't use interpolation
To keep it simple, in this specific case, I would go with just the window_set_size() function, to resize the window. In a drawing event of a controller object (a persistant object thats always ONCE in your game) you call the following functions:
CREATE:
Code:
application_surface_enable(false); //Dont make the game draw the application surface automatically
DRAW GUI END:
Code:
draw_surface_stretched(application_surface, 0, 0, display_get_gui_width(), display_get_gui_height()); //This draws the application surface over the entire GUI - the maximum size of the window
With the latter code you can resize the window all you want, but the game will keep being drawn into the entire window. Please take care that if you use another scale than 16:9 (640x360, 1280x720, 1920x1080) it will stretch.