【问题标题】:how to make a delay ursina sounds如何使延迟 ursina 的声音
【发布时间】:2021-11-30 10:15:26
【问题描述】:

所以我想在不终止 ursina 中的整个程序的情况下创建一个等待功能 例如

from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
from time import sleep
app = Ursina()
def input(keys):
    global inv
    if keys == 'left mouse down':
        print("hey")
        sleep(1) #here i can move in the game only after 1 sec
        print("done")
FirstPersonController()
app.run()

我想要做的是 { sleep(1) } 并且仍然可以移动 它在睡觉。 尝试过线程,但它只能工作一次

【问题讨论】:

    标签: python ursina


    【解决方案1】:

    有几种方法可以做到这一点,但最简单的可能是使用invoke。像这样:

    invoke(Audio, 'my_audio_file.ogg', delay=2) # will play after 2 seconds
    

    请记住,您不会为此执行 Audio('my_audio_file.ogg'),因为它会立即调用它。相反,您在要调用的函数之后传递参数,用逗号分隔,最后是延迟。延迟必须包含关键字,而不仅仅是数字。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-09
      • 1970-01-01
      • 2013-06-08
      • 2016-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多