Documentation
¶
Overview ¶
A one-shot timer managed by the scene tree, which emits OnTimeout on completion. See also SceneTree.CreateTimer.
As opposed to Timer, it does not require the instantiation of a node. Commonly used to create a one-shot delay timer as in the following example:
package main import ( "fmt" "graphics.gd/classdb/Node" "graphics.gd/classdb/SceneTree" ) func ExampleSceneTreeTimer(node Node.Instance) { fmt.Println("Timer started.") SceneTree.Get(node).CreateTimer(1.0).OnTimeout(func() { fmt.Println("Timer ended.") }) }
The timer will be dereferenced after its time elapses. To preserve the timer, you can keep a reference to it. See RefCounted.
Note: The timer is processed after all of the nodes in the current frame, i.e. node's Node.Process method would be called before the timer (or Node.PhysicsProcess if process_in_physics in SceneTree.CreateTimer has been set to true).
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsSceneTreeTimer() Instance
- func (self Instance) ID() ID
- func (self Instance) OnTimeout(cb func(), flags ...Signal.Flags)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetTimeLeft(value Float.X)
- func (self Instance) TimeLeft() Float.X
- func (self Instance) Virtual(name string) reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsSceneTreeTimer ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.SceneTreeTimer
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsSceneTreeTimer ¶
func (Instance) SetTimeLeft ¶
SetTimeLeft sets the property returned by [GetTimeLeft].