Kaplay.Timer
Modules
Comp
Values
addTimerComponent
addTimer(context, maxLoopsPerFrame: float=?)
=> Types.comp
Enable timer related functions like wait(), loop(), tween() on the game object.
let addTimer: ( Kaplay.Context.t, ~maxLoopsPerFrame: float=?,) => Kaplay.Types.comp
Return type
getMaxLoopsPerFrame
The maximum number of loops per frame allowed, to keep loops with sub-frame intervals from freezing the game.
let getMaxLoopsPerFrame: T.t => float
Parameters
Return type
loop
Run the callback every n seconds. If waitFirst is false (the default), the function will be called once on the very next frame, and then loop like normal.
let loop: ( T.t, float, unit => unit, ~maxLoops: int=?, ~waitFirst: bool=?,) => unit
Parameters
Return type
loopWithController
Run the callback every n seconds. If waitFirst is false (the default), the function will be called once on the very next frame, and then loop like normal.
let loopWithController: ( T.t, float, unit => unit, ~maxLoops: int=?, ~waitFirst: bool=?,) => Kaplay.TimerController.t
Parameters
Return type
setMaxLoopsPerFrame
The maximum number of loops per frame allowed, to keep loops with sub-frame intervals from freezing the game.
let setMaxLoopsPerFrame: (T.t, float) => unit
Parameters
Return type
tween
tween(context, from, to, duration in seconds, setValue, easeFunc=?) => unit
Useful to change a property of a Game Object over time.
k
->Context.tween(
~from=-15.,
~to_=0.,
~duration=0.5,
~setValue=Bird.setAngle(bird, ...),
)
let tween: ( T.t, ~from: 'v, ~to_: 'v, ~duration: float, ~setValue: 'v => unit, ~easeFunc: Kaplay.Types.easeFunc=?,) => unit
Return type
tweenWithController
tween(context, from, to, duration in seconds, setValue, easeFunc=?) => TweenController.t
Useful to change a property of a Game Object over time.
k
->Context.tween(
~from=-15.,
~to_=0.,
~duration=0.5,
~setValue=Bird.setAngle(bird, ...),
)
let tweenWithController: ( T.t, ~from: 'v, ~to_: 'v, ~duration: float, ~setValue: 'v => unit, ~easeFunc: Kaplay.Types.easeFunc=?,) => Kaplay.TweenController.t
Return type
wait
wait(t, duration in seconds, action?)
Run the callback after n seconds.
let wait: (T.t, float, ~action: unit => unit) => unit
Parameters
Return type
waitWithController
wait(t, duration in seconds, action?)
Run the callback after n seconds.
let waitWithController: ( T.t, float, ~action: unit => unit,) => Kaplay.TimerController.t