| Package | laya.utils |
| Class | public class Timer |
| Inheritance | Timer Object |
Timer 是时钟管理类。它是一个单例,不要手动实例化此类,应该通过 Laya.timer 访问。
| Property | Defined By | ||
|---|---|---|---|
| currFrame : int = 0 当前的帧数。 | Timer | ||
| currTimer : Number 当前帧开始的时间。 | Timer | ||
| delta : int [read-only]
帧之间的时间间隔,单位毫秒。
| Timer | ||
| scale : Number = 1 时针缩放。 | Timer | ||
| Method | Defined By | ||
|---|---|---|---|
Timer()
创建 Timer 类的一个实例。
| Timer | ||
callLater(caller:*, method:Function, args:Array = null):void
延迟执行。
| Timer | ||
clear(caller:*, method:Function):void
清理定时器。
| Timer | ||
clearAll(caller:*):void
清理对象身上的所有定时器。
| Timer | ||
frameLoop(delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true):void
定时重复执行(基于帧率)。
| Timer | ||
frameOnce(delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true):void
定时执行一次(基于帧率)。
| Timer | ||
loop(delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true, jumpFrame:Boolean = false):void
定时重复执行。
| Timer | ||
once(delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true):void
定时执行一次。
| Timer | ||
runCallLater(caller:*, method:Function):void
立即执行 callLater 。
| Timer | ||
runTimer(caller:*, method:Function):void
立即提前执行定时器,执行之后从队列中删除
| Timer | ||
toString():String 返回统计信息。 | Timer | ||
| currFrame | property |
public var currFrame:int = 0当前的帧数。
| currTimer | property |
public var currTimer:Number当前帧开始的时间。
| delta | property |
delta:int [read-only] 帧之间的时间间隔,单位毫秒。
public function get delta():int| scale | property |
public var scale:Number = 1时针缩放。
| Timer | () | Constructor |
public function Timer()
创建 Timer 类的一个实例。
| callLater | () | method |
public function callLater(caller:*, method:Function, args:Array = null):void延迟执行。
Parameters
caller:* — 执行域(this)。
| |
method:Function — 定时器回调函数。
| |
args:Array (default = null) — 回调参数。
|
| clear | () | method |
public function clear(caller:*, method:Function):void清理定时器。
Parameters
caller:* — 执行域(this)。
| |
method:Function — 定时器回调函数。
|
| clearAll | () | method |
public function clearAll(caller:*):void清理对象身上的所有定时器。
Parameters
caller:* — 执行域(this)。
|
| frameLoop | () | method |
public function frameLoop(delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true):void定时重复执行(基于帧率)。
Parameters
delay:int — 间隔几帧(单位为帧)。
| |
caller:* — 执行域(this)。
| |
method:Function — 定时器回调函数。
| |
args:Array (default = null) — 回调参数。
| |
coverBefore:Boolean (default = true) — 是否覆盖之前的延迟执行,默认为 true 。
|
| frameOnce | () | method |
public function frameOnce(delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true):void定时执行一次(基于帧率)。
Parameters
delay:int — 延迟几帧(单位为帧)。
| |
caller:* — 执行域(this)。
| |
method:Function — 定时器回调函数。
| |
args:Array (default = null) — 回调参数。
| |
coverBefore:Boolean (default = true) — 是否覆盖之前的延迟执行,默认为 true 。
|
| loop | () | method |
public function loop(delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true, jumpFrame:Boolean = false):void定时重复执行。
Parameters
delay:int — 间隔时间(单位毫秒)。
| |
caller:* — 执行域(this)。
| |
method:Function — 定时器回调函数。
| |
args:Array (default = null) — 回调参数。
| |
coverBefore:Boolean (default = true) — 是否覆盖之前的延迟执行,默认为 true 。
| |
jumpFrame:Boolean (default = false) — 时钟是否跳帧。基于时间的循环回调,单位时间间隔内,如能执行多次回调,出于性能考虑,引擎默认只执行一次,设置jumpFrame=true后,则回调会连续执行多次
|
| once | () | method |
public function once(delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true):void定时执行一次。
Parameters
delay:int — 延迟时间(单位为毫秒)。
| |
caller:* — 执行域(this)。
| |
method:Function — 定时器回调函数。
| |
args:Array (default = null) — 回调参数。
| |
coverBefore:Boolean (default = true) — 是否覆盖之前的延迟执行,默认为 true 。
|
| runCallLater | () | method |
public function runCallLater(caller:*, method:Function):void立即执行 callLater 。
Parameters
caller:* — 执行域(this)。
| |
method:Function — 定时器回调函数。
|
| runTimer | () | method |
public function runTimer(caller:*, method:Function):void立即提前执行定时器,执行之后从队列中删除
Parameters
caller:* — 执行域(this)。
| |
method:Function — 定时器回调函数。
|
| toString | () | method |
public function toString():String返回统计信息。
ReturnsString |