AnimationInstance
This is the AnimationInstance class. It represents a single animation instance
Functions
| Method | Returns | Description |
|---|---|---|
| AnimationInstance.new | AnimationInstance | Creates a new animation instance |
| AnimationInstance:start | AnimationInstance | Starts the animation |
| AnimationInstance:update | boolean | Updates the animation |
| AnimationInstance:complete | - | Called when the animation is completed |
AnimationInstance.new(element, animType, args, duration, easing)
Creates a new AnimationInstance
Parameters
elementVisualElementThe element to animateanimTypestringThe type of animationargstableThe animation argumentsdurationnumberDuration in secondseasingstringThe easing function name
Returns
AnimationInstanceThenew animation instance
AnimationInstance:start()
Starts the animation
Returns
AnimationInstanceselfThe animation instance
AnimationInstance:update(elapsed)
Updates the animation
Parameters
elapsednumberThe elapsed time in seconds
Returns
booleanWhetherthe animation is finished
AnimationInstance:complete()
Gets called when the animation is completed
Animation
This is the animation plugin. It provides a animation system for visual elementswith support for sequences, easing functions, and multiple animation types.
Functions
| Method | Returns | Description |
|---|---|---|
| Animation.registerAnimation | - | Registers a custom animation type |
| Animation.registerEasing | - | Adds a custom easing function |
| Animation.new | Animation | Creates a new animation |
| Animation:sequence | Animation | Creates a new sequence |
| Animation:onStart | - | Registers a callback for the start event |
| Animation:onUpdate | Animation | Registers a callback for the update event |
| Animation:onComplete | Animation | Registers a callback for the complete event |
| Animation:addAnimation | - | Adds a new animation to the sequence |
| Animation:start | Animation | Starts the animation |
| Animation:event | - | The event handler for the animation |
| Animation:stop | - | Stops the animation |
Animation.registerAnimation(name, handlers)
Registers a new animation type
Parameters
namestringThe name of the animationhandlerstableTable containing start, update and complete handlers
Usage
Animation.registerAnimation("fade", {start=function(anim) end, update=function(anim,progress) end})Animation.registerEasing(name, func)
Registers a new easing function
Parameters
namestringThe name of the easing functionfuncfunctionThe easing function (takes progress 0-1, returns modified progress)
Animation.new(element)
Creates a new Animation
Parameters
elementVisualElementThe element to animate
Returns
AnimationThenew animation
Animation:sequence()
Creates a new sequence
Returns
AnimationselfThe animation instance
Animation:onStart(callback)
Registers a callback for the start event
Parameters
callbackfunctionThe callback function to register
Animation:onUpdate(callback)
Registers a callback for the update event
Parameters
callbackfunctionThe callback function to register
Returns
AnimationselfThe animation instance
Animation:onComplete(callback)
Registers a callback for the complete event
Parameters
callbackfunctionThe callback function to register
Returns
AnimationselfThe animation instance
Animation:addAnimation(type, args, duration, easing)
Adds a new animation to the sequence
Parameters
typestringThe type of animationargstableThe animation argumentsdurationnumberThe duration in secondseasingstringThe easing function name
Animation:start()
Starts the animation
Returns
AnimationselfThe animation instance
Animation:event(event, timerId)
The event handler for the animation (listens to timer events)
Parameters
eventstringThe event typetimerIdnumberThe timer ID
Animation:stop()
Stops the animation immediately: cancels timers, completes running anim instances and clears the element property
VisualElement
Adds additional methods for VisualElement when adding animation plugin
Functions
| Method | Returns | Description |
|---|---|---|
| VisualElement.stopAnimation | - | Convenience to stop animations from the element |
| VisualElement:animate | Animation | Creates a new animation |
VisualElement.stopAnimation()
Convenience to stop animations from the element
VisualElement:animate()
Creates a new Animation Object
Returns
AnimationanimationThe new animation