Timeline
A timeline (engine.timeline()): chain to, set, call, label and wait to build it; it starts on the next frame unless made paused. Await it (or then) for its end; stop() ends it early (where it is).
Implements
Section titled “Implements”PromiseLike<void>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Timeline(
o?):Timeline
Use engine.timeline(opts).
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Timeline
Properties
Section titled “Properties”repeat
Section titled “repeat”repeat:
number
Plays after the first (-1: forever).
yoyo:
boolean
Every other play backwards.
onComplete?
Section titled “onComplete?”
optionalonComplete?: () =>void
Called when the last play ends.
Returns
Section titled “Returns”void
Accessors
Section titled “Accessors”duration
Section titled “duration”Get Signature
Section titled “Get Signature”get duration():
number
One play’s length, seconds.
Returns
Section titled “Returns”number
Get Signature
Section titled “Get Signature”get time():
number
Where the playhead is in the current play, seconds.
Returns
Section titled “Returns”number
paused
Section titled “paused”Get Signature
Section titled “Get Signature”get paused():
boolean
Paused by pause() (or made paused).
Returns
Section titled “Returns”boolean
finished
Section titled “finished”Get Signature
Section titled “Get Signature”get finished():
boolean
It ended (all its plays, or stop()).
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”to<
T>(target,to,seconds,ease?):this
Eases target’s numeric fields to to over seconds (as engine.tween), after the previous step or at.
Type Parameters
Section titled “Type Parameters”T extends object
Parameters
Section titled “Parameters”target
Section titled “target”T
Partial<Record<keyof T, number>>
seconds
Section titled “seconds”number
Ease | StepOptions | "linear" | "quadIn" | "quadOut" | "quadInOut" | "cubicOut" | "sineInOut" | "backOut" | "elasticOut" | "bounceOut"
Returns
Section titled “Returns”this
Example
Section titled “Example”engine.timeline().to(a, { x: 600 }, 0.5).to(b, { alpha: 0 }, 0.3, { at: '<' })set<
T>(target,values,at?):this
Sets fields at once, when the playhead gets there.
Type Parameters
Section titled “Type Parameters”T extends object
Parameters
Section titled “Parameters”target
Section titled “target”T
values
Section titled “values”Partial<Record<keyof T, number>>
Returns
Section titled “Returns”this
call()
Section titled “call()”call(
fn,at?):this
Calls fn when the playhead passes this point (either way: a yoyo calls it going back too).
Parameters
Section titled “Parameters”() => void
Returns
Section titled “Returns”this
label()
Section titled “label()”label(
name,at?):this
Names a point (default: the end so far), for at: 'name' and seek(‘name’).
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”this
wait()
Section titled “wait()”wait(
seconds):this
A pause of seconds at the end: the next step starts after it.
Parameters
Section titled “Parameters”seconds
Section titled “seconds”number
Returns
Section titled “Returns”this
pause()
Section titled “pause()”pause():
this
Stops the clock where it is (game pauses stop it anyway).
Returns
Section titled “Returns”this
resume()
Section titled “resume()”resume():
this
Starts or goes on after pause() or { paused: true }.
Returns
Section titled “Returns”this
stop()
Section titled “stop()”stop():
void
Ends it now, fields where they are; the promise resolves.
Returns
Section titled “Returns”void
seek()
Section titled “seek()”seek(
pos):this
Moves the playhead to a time or a label of the current play, writing the fields there.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”this
then()
Section titled “then()”then<
A,B>(ok?,fail?):Promise<A|B>
Attaches callbacks for the resolution and/or rejection of the Promise.
Type Parameters
Section titled “Type Parameters”A = void
B = never
Parameters
Section titled “Parameters”((v) => A | PromiseLike<A>) | null
((e) => B | PromiseLike<B>) | null
Returns
Section titled “Returns”Promise<A | B>
A Promise for the completion of which ever callback is executed.
Implementation of
Section titled “Implementation of”PromiseLike.then
update()
Section titled “update()”update(
dt):void
Advances by dt seconds of game time (the engine’s tweens call it).
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void