Timer

package
v0.0.0-...-568b220 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package Timer provides methods for working with Timer object instances.

Index

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 Any

type Any interface {
	gd.IsClass
	AsTimer() Instance
}

type Expanded

type Expanded [1]gdclass.Timer

func (Expanded) Start

func (self Expanded) Start(time_sec Float.X)

Starts the timer, or resets the timer if it was started already. Fails if the timer is not inside the tree. If [param time_sec] is greater than [code]0[/code], this value is used for the [member wait_time]. [b]Note:[/b] This method does not resume a paused timer. See [member paused].

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

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]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsTimer

func (self *Extension[T]) AsTimer() Instance

type ID

type ID Object.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.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.Timer

The [Timer] node is a countdown timer and is the simplest way to handle time-based logic in the engine. When a timer reaches the end of its [member wait_time], it will emit the [signal timeout] signal. After a timer enters the tree, it can be manually started with [method start]. A timer node is also started automatically if [member autostart] is [code]true[/code]. Without requiring much code, a timer node can be added and configured in the editor. The [signal timeout] signal it emits can also be connected through the Node dock in the editor: [codeblock] func _on_timer_timeout():

print("Time to attack!")

[/codeblock] [b]Note:[/b] To create a one-shot timer without instantiating a node, use [method SceneTree.create_timer]. [b]Note:[/b] Timers are affected by [member Engine.time_scale]. The higher the time scale, the sooner timers will end. How often a timer processes may depend on the framerate or [member Engine.physics_ticks_per_second].

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsTimer

func (self Instance) AsTimer() Instance

func (Instance) Autostart

func (self Instance) Autostart() bool

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IgnoreTimeScale

func (self Instance) IgnoreTimeScale() bool

func (Instance) IsStopped

func (self Instance) IsStopped() bool

Returns [code]true[/code] if the timer is stopped or has not started.

func (Instance) OnTimeout

func (self Instance) OnTimeout(cb func(), flags ...Signal.Flags)

func (Instance) OneShot

func (self Instance) OneShot() bool

func (Instance) Paused

func (self Instance) Paused() bool

func (Instance) ProcessCallback

func (self Instance) ProcessCallback() TimerProcessCallback

func (Instance) SetAutostart

func (self Instance) SetAutostart(value bool)

func (Instance) SetIgnoreTimeScale

func (self Instance) SetIgnoreTimeScale(value bool)

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetOneShot

func (self Instance) SetOneShot(value bool)

func (Instance) SetPaused

func (self Instance) SetPaused(value bool)

func (Instance) SetProcessCallback

func (self Instance) SetProcessCallback(value TimerProcessCallback)

func (Instance) SetWaitTime

func (self Instance) SetWaitTime(value Float.X)

func (Instance) Start

func (self Instance) Start()

Starts the timer, or resets the timer if it was started already. Fails if the timer is not inside the tree. If [param time_sec] is greater than [code]0[/code], this value is used for the [member wait_time]. [b]Note:[/b] This method does not resume a paused timer. See [member paused].

func (Instance) Stop

func (self Instance) Stop()

Stops the timer.

func (Instance) TimeLeft

func (self Instance) TimeLeft() Float.X

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

func (Instance) WaitTime

func (self Instance) WaitTime() Float.X

type TimerProcessCallback

type TimerProcessCallback int //gd:Timer.TimerProcessCallback
const (
	/*Update the timer every physics process frame (see [constant Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS]).*/
	TimerProcessPhysics TimerProcessCallback = 0
	/*Update the timer every process (rendered) frame (see [constant Node.NOTIFICATION_INTERNAL_PROCESS]).*/
	TimerProcessIdle TimerProcessCallback = 1
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL