我用GML编写了一个脚本,它应该在执行脚本之前等待几秒钟,但我尝试了一下,它不起作用。有人能帮帮忙吗?我不想使用等待/睡眠功能,因为这会延迟房间里的所有事情。下面是我的脚本。
//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;
}发布于 2016-05-30 20:10:51
据我所知,睡眠功能已经从GameMaker: Studio中删除了。您可以通过使用报警来制作自己的计时器脚本:
在触发器/暂停脚本中:
instance_deactivate_all(true);
alarm[0] = 60 //Your time in frames. If your room_speed is 60, this will be one second.那么在Alarm 0事件中,你可以这样做:
instance_reactivate_all();尽管这将停止渲染当前屏幕上的任何对象。您的另一个选择是创建一个global.timer = 60并停止每个对象if(global.timer > 0)的step事件,然后使用类似于控制器对象的东西来运行if(global.timer > 0) global.timer--;
遗憾的是,没有更简单的方法来做到这一点,但希望这两种方法就足够了。
https://stackoverflow.com/questions/37488772
复制相似问题