等待GameMaker:Studio

时间:2016-05-27 16:56:14

标签: 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 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;
}

1 个答案:

答案 0 :(得分:1)

据我所知,睡眠功能已从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--;

可悲的是,没有简单的方法可以做到这一点,但希望这两种方法就足够了。