【问题标题】:Game Maker Language sleep function without using alarmsGame Maker Language 睡眠功能,无需使用闹钟
【发布时间】:2017-11-28 20:12:45
【问题描述】:

gml 中没有内置睡眠功能,有没有办法在不使用闹钟的情况下执行睡眠功能?

【问题讨论】:

  • 你在哪里需要睡眠功能?我正在考虑来自 Windows 窗体的经典 System.Threading.Thread.Sleep() 方法,我自己并没有发现它有用。

标签: gml game-maker-language


【解决方案1】:

迟到的回复,但如果这是为了“冻结帧”(为了重音影响而短暂停顿),这可以通过繁忙的循环来完成:

/// busysleep(ms)
var t = current_time + argument0;
while (current_time < t) { }

【讨论】:

    【解决方案2】:

    创建变量 sleepStart 和 count,然后将它们设置为 0。在 step、begin step 或 end step 中,添加代码:

    if (sleepStart==1){count+=1}
    if (count==90){//That number can be whatever you want, depending on the length you want the delay.
    //Code to be executed after specified number of steps here.
    }
    

    当你想开始延迟时,将 sleepStart 设置为 1。

    如果您不知道,在默认的房间速度 30 下,90 步将是 3 秒。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-12
      相关资源
      最近更新 更多