Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Errors while following the menu tutorial

A topic by hamrath created Oct 24, 2023 Views: 84 Replies: 2
Viewing posts 1 to 3
(2 edits)

Hi, 

I tried to follow the menu group tutorial, but menu groups seem buggy. 

When I run my tutorial code I get the following error:

###
sprite_get_width argument 1 invalid reference to (sprite) at gml_Script_anon_GGL_sub_panel_gml_GlobalScript_scr_GGL_sub_panel_5522_GGL_sub_panel_gml_GlobalScript_scr_GGL_sub_panel (line 302) - var _baseW = sprite_get_width(sprite_index)  * image_xscale * owner.scale_relative.x;

###

If I check line 302 in scr_GGL_sub_panel there seem to be some variables not initialized. I tried to fix the code with the following modifications:

  • I initialized _baseW/_baseH with value 0 at 268, so they're declared earlier.
  • I also replaced lines 302-303 with the code from lines 280-287, but used _baseW/_baseH instead of _w/_h

That makes the code run. But the buttons still don't work perfectly. The hover section of the button is very small around the center. 

There seem to be more problems. Changing the font in parent_GGL_menu variables doesn't work. 

Also I'm not able to center the menu - but this could be a problem with the camera I use (I'm using stanncam from Github). GGL seems to ignore the resolution of the camera and only uses a fraction of the resolution, so items are cut off.  

FYI, these errors also happen to the demo room 12.

Could you please have a look at my problems? You probably can ignore the camera problem, as it seems to be an incompability with stanncam. I probably need to fix this myself.

Developer

Hi there,

Thanks for the feedback, i found the bug with the panels, somehow, the sub panel doesn't find it's own sprite when trying to rescale, i made a quick and dirty fix by setting the sprite to a default value if not found, along with an error message (which you can delete if you prefer).

I'll investigate further to make it clean, in the meantime, it should work as expected.


Regarding the fonts, the "font" variable on the menu object is the font used to draw the menu's name, not the sub menu elements,

i added 3 functions to GGL_sub_container to handle the fonts:

- Set_all_fonts(font) => sets the font of the container's label and all of it's sub elements

- Set_sub_font(element, font) => sets the font of a particular element inside the container

- Set_all_sub_fonts() => sets the labels of all the sub elements inside the container


I'm not familiar with stanncam but i'll look into it, GGL relies on display_get_gui_width() and display_get_gui_height() to calculate the center position, could your camera modify the GUI size perhaps?

GGL_v1.10.0 is awailable with the aforementioned fixes!

Wow, that was fast! Thanks a lot, it works now. 

There is a small ghost panel sprite on the screen though. This doesn't happen in demo room 12 or it's underneath one of the buttons, I'm not sure.

I investigated the camera problem a little further. stanncam disables application_surface and uses the Post-Draw event to draw everything. I added Update_GUI_dimensions() to a Post-Draw event in obj_GGL_controller and the menu is drawn properly. I still have to figure out how to center the items correctly on the screen though.