GM:S 1.4 how to make the text disappear 30 seconds after appearing

Discussion in 'Programming' started by Linda Cell, Jul 14, 2019 at 12:32 PM.

  1. Linda Cell

    Linda Cell Member

    Joined:
    Sunday
    Posts:
    1
    Hello GMS, i'm working the first game with GMS 1.4 and i got the trouble with text. As i want the text will appear 30 seconds and then it will disappear, how can i do this? I found some the solution in the google but when i follow it, it just disappear about 2 seconds.
    Thank for reading.
     
  2. Annoyed Grunt

    Annoyed Grunt Member

    Joined:
    Jun 20, 2016
    Posts:
    110
    Hard to say without posting the code (which you should do), but chances are that the solution found through google has some kind of counter/alarm that handles after how much time the text should disappear. Simply change that from 2 seconds to 30 seconds (remembering that 30 seconds in steps is going to be 30 * room_speed).
     
  3. marasovec

    marasovec Member

    Joined:
    Sep 15, 2016
    Posts:
    288
    Create event:
    Code:
    alpha = 0;
    show_text = true;
    text = "blah blah";
    alarm[0] = room_speed * 30; // room_speed is basically 1 second
    
    Alarm 0:
    Code:
    show_text = false;
    
    Draw event:
    Code:
    if show_text alpha += 0.01; // appearing
    else alpha -= 0.01; // disappearing
    alpha = clamp(alpha, 0, 1); // it's not necesary but I like to keep the value between 0 and 1
    
    draw_set_alpha(alpha); // set the alpha for the text
    draw_text(x, y, text);
    draw_set_alpha(1); // reset the alpha for other objects
    
     
  4. lvls3dx

    lvls3dx Member

    Joined:
    Sunday
    Posts:
    7
    Other people already pointed great solutions. Just have in mind that if you don't feel confident using alarms you may also just create some basic timer like:
    Code:
     
    if ""wathever condition""{
    my_timer = 30;
    }
    
    //and the in your step event just put a countdown
    
    if my_timer !=0 {
    my_timer = my_timer -1;
    }
    
    //and finally add another conditional for when countdown reaches zero
    
    if my_timer =0 {
    """whatever condition"""";
    }
    
    
     

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