Core. Timer

Timer Clock management class. It is a singleton, and do not manually instantiate this class. It should be accessed through Laya.timer.

Constructor

new Timer()

Establish Timer An instance of a class.

Member

currFrame :int

The number of the current frame.
Default Value:
  • 0

currTimer :Number

Time at which the current frame starts.
Default Value:
  • null.now

delta :int

The time interval between two frames, in milliseconds.

scale :Number

Zoom clockwise.
Default Value:
  • 1

Methods

callLater(caller, method, argsopt)

Deferred execution.
Parameters:
Name Type Attributes Default Description
caller Object Execute domain (this).
method function Timer callback function.
args Array <optional>
null args Callback parameter.

clear(caller, method)

Clean timer.
Parameters:
Name Type Description
caller Object Execute domain (this).
method function Timer callback function.

clearAll(caller)

Clear all timers on the object.
Parameters:
Name Type Description
caller Object Execute domain (this).

frameLoop(delay, caller, method, argsopt, coverBefore)

Timed repeat execution (based on frame rate).
Parameters:
Name Type Attributes Default Description
delay int How many frames (frames per frame) are spaced?.
caller Object Execute domain (this).
method function Timer callback function.
args Array <optional>
null args Callback parameter.
coverBefore Boolean Whether or not the previous delay execution is covered, defaults to true.

frameOnce(delay, caller, method, argsopt, coverBefore)

Timed execution (based on frame rate).
Parameters:
Name Type Attributes Default Description
delay int Delays several frames (frames per unit).
caller Object Execute domain (this).
method function Timer callback function.
args Array <optional>
null args Callback parameter.
coverBefore Boolean Whether or not the previous delay execution is covered, defaults to true.

loop(delay, caller, method, argsopt, coverBefore, jumpFrame)

Timed repeat execution.
Parameters:
Name Type Attributes Default Description
delay int Interval time (ms per unit).
caller Object Execute domain (this).
method function Timer callback function.
args Array <optional>
null args Callback parameter.
coverBefore Boolean Whether or not the previous delay execution is covered, defaults to true.
jumpFrame Boolean The clock is skipping. Time based callback, in the unit time interval, if you can perform multiple callbacks, for performance reasons, the engine defaults to only once. After setting the jumpFrame=true, the callback is executed several times in succession

once(delay, caller, method, argsopt, coverBefore)

Execute once.
Parameters:
Name Type Attributes Default Description
delay int Delay time (in milliseconds).
caller Object Execute domain (this).
method function Timer callback function.
args Array <optional>
null args Callback parameter.
coverBefore Boolean Whether or not the previous delay execution is covered, defaults to true.

runCallLater(caller, method)

Execute callLater immediately.
Parameters:
Name Type Description
caller Object Execute domain (this).
method function Timer callback function.

runTimer(caller, method)

Execute the timer immediately ahead of time and remove it from the queue after execution
Parameters:
Name Type Description
caller Object Execute domain (this).
method function Timer callback function.

toString()

Return statistics.