godot-start/zfoo/scheduler/TimeUtils.gd

16 lines
394 B
GDScript
Raw Normal View History

2021-10-03 09:23:08 +00:00
extends Object
const timestamp = [0]
# 获取精确的时间戳
static func currentTimeMillis() -> int:
var currentTimeMillis = OS.get_system_time_msecs()
timestamp[0] = currentTimeMillis
return currentTimeMillis
# 获取最多只有一秒延迟的粗略时间戳,适用于对时间精度要求不高的场景,最多只有一秒误差
static func now() -> int:
return timestamp[0]