GMS 2 [SOLVED] Draw_Gui not working anymore

Discussion in 'Programming' started by Vinicius Alvarenga, Jul 13, 2019.

Tags:
  1. Vinicius Alvarenga

    Vinicius Alvarenga Member

    Joined:
    Aug 2, 2018
    Posts:
    19
    Soooooo, I was using an old version of GMS2 (2.1.4.285) so I decided to update it, everything went perfect, but the draw_gui simply stopped working, I was drawing a Crosshair and it has simply disapeared from the hud.
    This is the code that I'm using to the Crosshair:

    var xxx = display_get_gui_width()/2;
    var yyy = display_get_gui_height()/2;
    draw_sprite (sprite24, 0, xxx, yyy)

    Thx.
     
  2. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    700
    Have you tried checking your GUI size in the debugger or by printing it to the console? If you use some static values instead for the crosshair do you see the sprite?

    Just to get some insight on what may cause it to disappear, since the draw gui event was definitely not removed in newer versions and works as usual.
     
  3. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,453
    Work backwards to try and work out why.

    Use show_debug_message() or show_message() to make sure the event is being called, if it's not check the object is in the room.

    If it is, draw the sprite at a hardcoded x/y like 100,100 and see if that draws. If not check that you haven't set draw_set_alpha(0) somewhere beforehand and not reset it before drawing it.

    If that fails try another object.

    Also check things like layer visibility, object visibility etc

    edit: ninja'd :p
     
  4. Vinicius Alvarenga

    Vinicius Alvarenga Member

    Joined:
    Aug 2, 2018
    Posts:
    19
    I tried to put some static values and nothing happened, I tried to put show_debug_message() to see if something shows up and nothing appeared but when I put show_message it appears, tried to put draw_set_alpha(1) and still nothing. The visible option it's marked, about creating another object, i'm putting this code in the player object, soooo :/
     
  5. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    700
    show_debug_message outputs to the console, it's not supposed to show up load show_message does. With just this information it is really difficult for me to guess where the problem lies, it is important to include some more details when you reply like the actual code you used to test. Can you please output the values of display_get_gui_width and display_get_gui_height to begin with, as well as the game resolution (width and height in pixel)?
     
  6. Vinicius Alvarenga

    Vinicius Alvarenga Member

    Joined:
    Aug 2, 2018
    Posts:
    19
    Ok, Now I understand how to use show_debug_message(), so yes, it showed the message, about the width and the height, i'm using a resolution of 800x600.

    To test with some static values, I used:
    draw_sprite (sprite24, 0, 300, 400);

    To test with enabling the alpha, I used:

    var xxx = display_get_gui_width()/2;
    var yyy = display_get_gui_height()/2;
    draw_sprite (sprite24, 0, xxx, yyy)
    draw_set_alpha(1);

    Everything in the player object in Draw_GUI event.
     
  7. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    700
    Why did you set the alpha to 1 after drawing the sprite? If you think that the alpha is the problem, change it before drawing. You still haven't told us the gui width and height... Also, if you draw the crosshair in the regular draw event with static values, does it show up? (even if it is in the wrong place obviously)
     
    Vinicius Alvarenga and rIKmAN like this.
  8. Vinicius Alvarenga

    Vinicius Alvarenga Member

    Joined:
    Aug 2, 2018
    Posts:
    19
    Ok, so i discovered the problem,thanks to you Catan, the problem was the GUI size, so i just used display_set_gui_size() to resize the GUI and it worked perfectly, thx.
     
    Catan likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice