Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

SceneTreeTimer

繼承: RefCounted < Object

一次性計時器。

說明

由場景樹管理的一次性計時器,會在完成時發出 timeout。另見 SceneTree.create_timer()

Timer 不同,它不需要產生實體節點。常用於建立一次性的延遲計時器,如下面的例子所示:

func some_function():
    print("計時開始。")
    await get_tree().create_timer(1.0).timeout
    print("計時結束。")

達到時間後,會釋放對該計時器的引用。如果要保留該計時器,你可以保持對它的引用。見 RefCounted

注意:對計時器的處理發生在目前影格的所有節點節後,即節點的 Node._process() 方法是在計時器之前呼叫的(如果 SceneTree.create_timer()process_in_physicstrue則為 Node._physics_process())。

屬性

float

time_left


訊號

timeout() 🔗

當計時器到 0 時發出。


屬性說明

float time_left 🔗

  • void set_time_left(value: float)

  • float get_time_left()

剩餘時間(單位為秒)。