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.
Checking the stable version of the documentation...
SceneTreeTimer
繼承: RefCounted < Object
一次性計時器。
說明
由場景樹管理的一次性計時器,會在完成時發出 timeout。另見 SceneTree.create_timer()。
與 Timer 不同,它不需要產生實體節點。常用於建立一次性的延遲計時器,如下面的例子所示:
func some_function():
print("計時開始。")
await get_tree().create_timer(1.0).timeout
print("計時結束。")
public async Task SomeFunction()
{
GD.Print("計時開始。");
await ToSignal(GetTree().CreateTimer(1.0f), SceneTreeTimer.SignalName.Timeout);
GD.Print("計時結束。");
}
達到時間後,會釋放對該計時器的引用。如果要保留該計時器,你可以保持對它的引用。見 RefCounted。
注意:對計時器的處理發生在目前影格的所有節點節後,即節點的 Node._process() 方法是在計時器之前呼叫的(如果 SceneTree.create_timer() 的 process_in_physics 為 true則為 Node._physics_process())。
屬性
訊號
timeout() 🔗
當計時器到 0 時發出。
屬性說明
剩餘時間(單位為秒)。