Wait 在GameMaker中等待:Studio

Wait 在GameMaker中等待:Studio,wait,gml,Wait,Gml,我用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

我用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;
}

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

在触发/暂停脚本中:

instance_deactivate_all(true);
alarm[0] = 60 //Your time in frames. If your room_speed is 60, this will be one second.
然后在报警0事件中,您可以执行以下操作:

instance_reactivate_all();
尽管这将停止渲染屏幕上当前可能有的任何对象。 您的另一个赌注是创建一个
global.timer=60
并停止每个对象的步骤事件
if(global.timer>0)
,然后让类似于控制器的对象运行
if(global.timer>0)global.timer--


遗憾的是,现在再也没有简单的方法了,但希望这两种方法足够了。

好的,但我想知道我的脚本是否能工作。我只想等待一个对象,而不是所有对象。我的最佳选择是使用另一个,我可以添加一个秒变量,然后将其乘以房间速度,创建全局计时器。然后我可以使用第二个脚本,并对其进行修改,使其在动画中淡入淡出。在这种情况下,您可以有选择地将if语句放入要暂停的对象中。任何未检查全局计时器的对象将继续正常执行。