跳转至

Timer

继承

Node

简要描述

倒数计时器。

描述

递减指定的间隔,并在达到0时发出信号。可以设置为重复或“单次”模式。

成员

类型 属性名 默认值
bool autostart false
bool one_shot false
bool paused
int process_mode 1
float time_left
float wait_time 1.0

方法

返回值类型 方法名称
bool is_stopped() const
void start(time_sec: float = -1)
void stop()

信号

  • timeout

计时器达到0时发出。


枚举

enum TimerProcessMode: - TIMER_PROCESS_PHYSICS = 0

在物理步骤中,每帧更新计时器(固定帧速率处理)。

  • TIMER_PROCESS_IDLE = 1

在每帧的空闲时间更新计时器。


常量

成员说明

  • bool autostart
Default false
setter set_autostart(value)
getter has_autostart
  • bool one_shot
Default false
setter set_one_shot(value)
getter is_one_shot
  • bool paused
setter set_paused(value)
getter is_paused
  • int process_mode
Default 1
setter set_timer_process_mode(value)
getter get_timer_process_mode
  • float time_left
getter get_time_left
  • float wait_time
Default 1.0
setter set_wait_time(value)
getter get_wait_time

方法说明

  • is_stopped is_stopped() const

如果计时器已停止,则返回true


  • start start(time_sec: float = -1)

启动计时器。如果time_sec > 0,则设置wait_timetime_sec。0。这也将剩余时间重置为wait_time`。

**注意:**此方法将不会恢复暂停的计时器。请参照paused.


  • stop stop()

停止计时器。