显示当前时间Game Maker

Pan*_*a97 3 datetime game-maker

我一直在努力简单地显示当前时间,无法在任何地方找到解决方案......对于错位的帖子感到抱歉.

我想要的只是在用户的电脑或手机上显示时间.

我能做的就是让时间显示在一个盒子里,而不是让它每秒都显示和更新.

这是我目前的代码

//store the current time
t=date_current_datetime();

//get the hour portion of that time
h=date_get_hour(t);

//get the minute portion of the time.
m=date_get_minute(t);

//get the second potion of the time
s=date_get_second(t);

//show the time
txt="The current time is:"+string(h)+":"+string(m)+":"+string(s);
show_message(txt); 
Run Code Online (Sandbox Code Playgroud)

希望这个游戏制作者代码有意义,感谢任何帮助.

Dmi*_*7ry 5

好的,添加到Create活动:

txt = "";
alarm[0] = 1;
Run Code Online (Sandbox Code Playgroud)

将代码移动到Alarm 0事件:

//store the current time
t = date_current_datetime();

//get the hour portion of that time
h = date_get_hour(t);

//get the minute portion of the time.
m = date_get_minute(t);

//get the second potion of the time
s = date_get_second(t);

//show the time
txt = "The current time is: " + string(h) + ":" + string(m) + ":" + string(s);

alarm[0] = room_speed;
Run Code Online (Sandbox Code Playgroud)

最后 - Draw事件:

draw_text(10, 10, txt);
Run Code Online (Sandbox Code Playgroud)

当然你也可以使用Draw GUI事件或视图坐标

draw_text(view_xview[0] + 10, view_yview[0] + 10, txt);
Run Code Online (Sandbox Code Playgroud)

  • 哇第一次工作,正是我需要的!多谢 (2认同)