Timer
顾名思义,它就是个计时器
新建一个Node
类型的根节点
将其命名为"Game"
为"Game"添加一个
Timer
类型的子节点
Timer
的属性和信号
Timer
的属性很简单
Process Mode
Idle
表示在_process
中更新;Physics
表示在_physics_process
中更新One Shot
是否是一次性的Wait Time
间隔时间,单位是秒Auto Start
是否自动启动
Timer
的信号也很简单,到了Wait Time
的时间就发出一个timeout
信号
我们在"Timer"加一个脚本
extends Timer
func _ready():
connect("timeout",self,"_on_timeout")
func _on_timeout():
print("到时间了")
设置属性
然后把间隔时间WaitTime
设为0.2秒,开启AutoStart
这样我们定义的_on_timeout
方法每隔0.2秒就会被调用一次了