Class: Clock
时钟对象,默认内部会使用 performance.now 否则会
回退到 Date.now()
.
const clock = new Clock();
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new Clock(running?
): Clock
Constructor
Parameters
Name | Type | Default value | Description |
---|---|---|---|
running | boolean | true | 时钟状态 |
Returns
Defined in
Properties
running
• running: boolean
Defined in
Methods
start
▸ start(): void
启动时钟
Returns
void
Defined in
stop
▸ stop(): void
停止时钟
Returns
void
Defined in
reset
▸ reset(): void
重置时钟状态
Returns
void
Defined in
getElapsedTime
▸ getElapsedTime(): number
获取自时钟启动以来经过的秒数
Returns
number
Defined in
getDelta
▸ getDelta(): number
计算时钟总启动时间,并将当前时间设置赋值到 lastTime
Returns
number