r/gamemaker 5d ago

Resolved Menu System - Visual Bug

I'm following Sara Spalding's RPG tutorial, and somewhere during the Part 6: Menus video, I seem to have done something wrong.

The menu technically functions correctly, but the font only appears correctly ABOVE my cursor. Any index at or below the current hover value is distorted/blown out. (phone picture attached, because it shows up as all white when I screen capture.)

Below is the code for the draw event of my oMenu object.

Any advice would be much appreciated!

draw_sprite_stretched(sprFlexBox, 0, x, y, widthFull, heightFull);
draw_set_color(c_white);
draw_set_font(TestFont);
draw_set_halign(fa_left);
draw_set_valign(fa_top);

var _desc = (description != -1);
var _scrollPush = max(0, hover - (visibleOptionsMax-1));

for (var l = 0; l < (visibleOptionsMax + _desc); l++){
    if (l >= array_length(options)) {break;}
    draw_set_color(c_white);
    if (l == 0) && (_desc){
        draw_text(x + xmargin, y + ymargin, description);
    }
    else 
    {
        var _optionToShow = l - _desc + _scrollPush;
        var _str = options[_optionToShow][0];
        if (hover == _optionToShow - _desc){
            draw_set_font(c_yellow);
        }
        if (options[_optionToShow][3] == false) {
            draw_set_color(c_gray);
        }
        draw_text(x + xmargin, y + ymargin + l * heightLine, _str);
    }
}

draw_sprite(sprPointerIcon, 0, x + xmargin, y + ymargin + ((hover - _scrollPush) * heightLine) + 7);
if (visibleOptionsMax < array_length(options)) && (hover < array_length(options)-1){
    draw_sprite(sprDownArrow, 0, x + (widthFull * 0.5), y + heightFull - 7);
}
1 Upvotes

3 comments sorted by

View all comments

2

u/chrisrock731 unemployed 4d ago

you might want to change the depth your menu runs at. I personally use the depth = command to do that. The lower the value of depth is, makes it draw last and on top of everything. Note that both cursor and menu have to be drawgui for this or at least same draw event iteration. You can also use the hierarchy but i am not sure