首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >显示当前时间Game Maker

显示当前时间Game Maker
EN

Stack Overflow用户
提问于 2015-07-13 01:17:36
回答 1查看 2.1K关注 0票数 3

我一直在努力简单地显示当前时间,但找不到一个解决方案,anywhere...so为错误的帖子道歉。

我只想在用户的pc或手机上显示时间。

我能做的是让时间显示在框中的消息,而不是它只是显示和更新每秒。

这是我当前的代码

代码语言:javascript
复制
//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); 

希望这个gamemaker代码有意义,谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2015-07-13 02:12:48

好的,添加到Create事件:

代码语言:javascript
复制
txt = "";
alarm[0] = 1;

将您的代码移动到Alarm 0事件:

代码语言:javascript
复制
//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;

和last - Draw事件:

代码语言:javascript
复制
draw_text(10, 10, txt);

当然,您也可以使用Draw GUI事件或视图坐标,例如

代码语言:javascript
复制
draw_text(view_xview[0] + 10, view_yview[0] + 10, txt);
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31370455

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档