Skip to content
Benedict Allen edited this page Nov 15, 2015 · 3 revisions

Animation class.

The Animation class is used to handle the animation of single values with multiple keyframes and pauses.

Callbacks

onFinish()

Animation:onFinish()

Called when the whole animation finishes.

onFrameFinished()

Animation:onFrameFinished( number frame )

Called when an individual frame (including the last one, and pauses) finishes.

Variables

rounded

Animation.rounded - boolean

Defines whether the result of the animation should be rounded, for use with things like positions, which must be integers.

Methods

addKeyFrame()

This method is chainable.

Animation:addKeyFrame( number initial, number final, number time = 0.5, optional function easing )

Adds a frame to the animation. The animation's value will go between initial and final using the easing provided until it has completed, at which point it will move onto the next frame.

Animation:addKeyFrame( number initial, number final, number duration = 0.5, string easing )

Same as above, but takes "transition", "entrance" and "exit" as easing.

addPause()

This method is chainable.

Animation:addPause( number duration )

Adds a pause to the animation. duration seconds will pass before advancing to the next frame after the pause.

setRounded()

This method is chainable.

Animation:setRounded()

Sets the rounded variable of the animation to true

update()

Animation:update( number dt )

Updates the animation, re-calculating its value based on its frames and pauses. dt is the time between now and when it was last updated.

finished()

boolean finished = Animation:finished()

Returns whether the animation has finished.

Clone this wiki locally