Mac OSX Trying to Draw GUI Text on Enemy Death

Discussion in 'Programming' started by myemanisbob, May 22, 2019.

  1. myemanisbob

    myemanisbob Member

    Joined:
    Apr 20, 2019
    Posts:
    8
    As the Title suggests, I'm trying to draw text on the screen whenever an enemy dies. My dead enemy is a separate object, so I'm writing all of this code on his create event, so that it triggers the second he dies. The game is not crashing, but no text is appearing. What am I doing wrong? All I want is the letter F to appear on the top left of the screen when an enemy dies.
    Code:
    gui_width = display_get_gui_width();
    gui_height = display_get_gui_height();
    gui_margin = 32;
    text_x = gui_width + 200;
    text_y = gui_height + gui_margin;
    text_itemheight = font_get_size(fnt_menu);
    draw_set_font(fnt_menu);
    draw_set_halign(fa_left);
    draw_set_valign(fa_top);
    var txt = "F"
    var xx = text_x;
    var yy = text_y - (text_itemheight * 1.5);
    draw_set_color(c_black);
    draw_text(xx,yy,txt);
    
     
  2. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,016
    You can only use draw commands in the draw/gui events. Also, the create event only fires once, so even if you could do it there, it would only exist for 1 frame (which is presumably 1/60th of a second). Try moving it to a gui draw event and seeing if it works then.

    It might be worth reviewing the manual on what events do and what order they go in as well: https://docs2.yoyogames.com/source/_build/2_interface/1_editors/events/index.html
     
    DukeSoft likes this.
  3. Tony Brice

    Tony Brice Member

    Joined:
    Feb 4, 2017
    Posts:
    67
    First question. What colour is your background in the game? I ask this because you're setting the text colour to black.
     
  4. BattleRifle BR55

    BattleRifle BR55 Member

    Joined:
    Jun 24, 2016
    Posts:
    965
    Also, don't get into the habit of storing variables into variables redundantly.
     
  5. myemanisbob

    myemanisbob Member

    Joined:
    Apr 20, 2019
    Posts:
    8
    No change in the Draw GUI event. Also the background is grey so the black should show up.
     
  6. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,016

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