首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在GameMaker等待:直播间

在GameMaker等待:直播间
EN

Stack Overflow用户
提问于 2016-05-28 00:56:14
回答 1查看 11.3K关注 0票数 1

我用GML编写了一个脚本,它应该在执行脚本之前等待几秒钟,但我尝试了一下,它不起作用。有人能帮帮忙吗?我不想使用等待/睡眠功能,因为这会延迟房间里的所有事情。下面是我的脚本。

代码语言:javascript
复制
//Rename this script according to what you want to wait for
//Here is how many seconds we want to wait.
var seconds = 0;
//We will multiply the amount of seconds by the room speed, and store it in a variable
var waittime = seconds * room_speed;
//Then, we will define a script for later
var script = "Your Script here";
//Then, we will add a question, and it will ask if the room speed is the same as the wait time
if (room_speed == waittime or room_speed > waittime) {
    //Then, if the amount of room speed is the same as the wait time, then execute the script
    script_execute(script);
}
else {
    //But if the amount of seconds is not equal, or greater than the wait time, then just add the fps to the wait time-
    waittime += fps;
}
EN

回答 1

Stack Overflow用户

发布于 2016-05-30 20:10:51

据我所知,睡眠功能已经从GameMaker: Studio中删除了。您可以通过使用报警来制作自己的计时器脚本:

在触发器/暂停脚本中:

代码语言:javascript
复制
instance_deactivate_all(true);
alarm[0] = 60 //Your time in frames. If your room_speed is 60, this will be one second.

那么在Alarm 0事件中,你可以这样做:

代码语言:javascript
复制
instance_reactivate_all();

尽管这将停止渲染当前屏幕上的任何对象。您的另一个选择是创建一个global.timer = 60并停止每个对象if(global.timer > 0)的step事件,然后使用类似于控制器对象的东西来运行if(global.timer > 0) global.timer--;

遗憾的是,没有更简单的方法来做到这一点,但希望这两种方法就足够了。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37488772

复制
相关文章

相似问题

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