GameMaker My game cant be minimized

T

Trex0n35

Guest
So I have a bit of code that resizes the scale of the GUI for fullscreen but whenever my game is minimized it comes up with an error because it cant get the width and height of the GUI.

Code:
if _fullscreen {
window_set_fullscreen(true)
display_set_gui_size(display_get_gui_width(),display_get_gui_height())
surface_resize(application_surface,display_get_gui_width(),display_get_gui_height())
} else {
window_set_fullscreen(false)
display_set_gui_size(window_get_width(),window_get_height())
surface_resize(application_surface,window_get_width(),window_get_height())
}
If anyone can figure out how I can prevent this error, that would be great!!!

############################################################################################
ERROR in
action number 1
of Draw Event
for object ob_control:

Invalid surface dimensions
at gml_Object_ob_control_Draw_74
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_ob_control_Draw_74 (line -1)
 
Last edited by a moderator:

Binsk

Member
Show us the actual error. My guess is that the surface hasn't been recreated yet after maximising. If this is the case, make sure the application surface exists before messing with it.
 
T

TimothyAllen

Guest
Your window dimensions are probably coming up as 0 when minimized... So do a bit of defensive programming.
 
Top