• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Can I use Drawing Surface Functions in Draw GUI Event???

Petrik33

Member
Actually the questions lies in the heading, but here is the code that contains problem:
//Draw Gui Event
GML:
//Editor Window
Draw9SlicedBox(spr_level_editor_button,0,0,editor_window_width,editor_window_height);

//Buttons
DrawSetText(editor_font,c_white,fa_middle,fa_center)
for(var i=0;i<array_length_1d(button);i++)
{
    if (button_cursor == i) var button_sprite = spr_level_editor_button_pressed;
    else var button_sprite = spr_level_editor_button;
    Draw9SlicedBox(button_sprite,button_edges[i],0,button_edges[i+1],button_height);
    draw_text((button_edges[i]+button_edges[i+1])/2,button_height/2,button[i]);
}

//Panel Content
switch(button_cursor)
{
    case CONTENT.OBJECTS:
        if(!surface_exists(panel_surface)) panel_surface = surface_create(editor_window_width,editor_window_height)
        
        surface_set_target(panel_surface)
        draw_clear_alpha(c_black,0);
        
        var _objects_list = editing_content[@CONTENT.OBJECTS]
        var draw_height_progress = 0;
        var previous_object_height = 0;
        for(var i = 0;i<ds_list_size(_objects_list);i++)
        {
            var _object = _objects_list[| i];
            draw_sprite
            (
                _object.sprite_index,//sprite
                0,//subImage
                editor_window_width* ( (i mod 2) * 2 + 1) /4 + _object.sprite_xoffset - _object.sprite_width/2,//x
                draw_height_progress+distance_between_objects+_object.sprite_yoffset - _object.sprite_height/2-scrolling_progress*editor_window_height//y
            )
            draw_height_progress+=max(_object.sprite_height-previous_object_height,0)
            previous_object_height = _object.sprite_height;
        }
        surface_reset_target();
        draw_surface(panel_surface,0,button_height)
    break;
}
So Can I use surfaces in the draw GUI event and if not how can I draw the UI in simple draw event.
!!! If you don't understand why I need to draw surface in this case, please check the Thread I created before, called "How to Create Scrolling Panel???"
 
Top