How can i make text showing up after some period of time?

68 views Asked by At

I am a newbie. i wanted make little text showing under the door after player reaching the door and waiting some time, but text doesn't show up. text part works fine, but " call_later" not.

var _callback = function()
{
    draw_set_font(v_lol);
    draw_set_colour(c_yellow);
    draw_text(x, y-30, "press key up");
}
        
if place_meeting(x,y,obj_player) = true 
{ 
    var _handle  = call_later(10,time_source_units_seconds,_callback);
}
1

There are 1 answers

0
Steven On

I'm not familiar with call_later, but it looks like you followed the example in the Gamemaker Documents: https://manual.yoyogames.com/GameMaker_Language/GML_Reference/Time_Sources/call_later.htm

What I assume what happens is that the countdown for call_later resets as long as you're in front of the door. (the document don't specify if it's in the Create or Step Event) Maybe you can put a boolean check so it only goes through the if-statement once until it has showed the message. (Maybe there are better alternates, but this is more for confirmation sake)

Example:

//For Create Event:
bool beginCountDown = false;

//Step Event:
var _callback = function()
{
    draw_set_font(v_lol);
    draw_set_colour(c_yellow);
    draw_text(x, y-30, "press key up");
    beginCountDown = false;
}
        
if (place_meeting(x,y,obj_player) = true && beginCountDown == false)
{ 
    var _handle  = call_later(10,time_source_units_seconds,_callback);
    beginCountDown = true;
}