Script PICO-TweenMachine

PICO-TweenMachine - An additional small extension library for PICO-Tween that acts as a wrapper, powering all tween related functionality internally, rather than having large chunks of tweening cluttering the codebase.

Info:

  • Copyright: Joeb Rogers 2018
  • License: MIT
  • Author: Joeb Rogers

Functions

tween_machine:update () Calls update() on all current tween instances.
tween_machine:add_tween (instance) Adds a created tween instance to the table.
__tween:register_step_callback (func) Registers the passed in function as a step callback, to be called in update() after a new value has been set.
__tween:register_finished_callback (func) Registers the passed in function as a finished callback, to be called at the end of update() after the tween has been marked as finished.
__tween:init () Sets the tween's necessary fields prior to being ran.
__tween:restart () Restarts the tween's necessary fields in order to be ran again.
__tween:update () Updates the tween object.
__tween:remove () Removes the tween from the wrapper object.

Tables

tween_machine The main wrapper object of the library.
__tween The base table for all tween objects.


Functions

tween_machine:update ()
Calls update() on all current tween instances.
tween_machine:add_tween (instance)
Adds a created tween instance to the table. The passed in object only needs to define the fields it needs to change, the rest will be defaulted to the base tween object. For example: tween_machine:add_tween({ func = linear, v_start = 10, v_end = 5 })

Parameters:

  • instance The tween object to add to the machine.

Returns:

    Returns the tween object.
__tween:register_step_callback (func)
Registers the passed in function as a step callback, to be called in update() after a new value has been set.

Parameters:

  • func The function to be called every step.
__tween:register_finished_callback (func)
Registers the passed in function as a finished callback, to be called at the end of update() after the tween has been marked as finished.

Parameters:

  • func The function to be called when finished.
__tween:init ()
Sets the tween's necessary fields prior to being ran. Called automatically when added to the wrapper object or when restarted.
__tween:restart ()
Restarts the tween's necessary fields in order to be ran again.
__tween:update ()
Updates the tween object. Gets the current value for the tween from the set function and will pass it through all the registered step callbacks. Will set the tween as finished when the elapsed time passes the duration and will pass the tween object to all registered finished callback functions.

Returns:

    Will return early if the tween is finished or no easing function has been set.
__tween:remove ()
Removes the tween from the wrapper object.

Tables

tween_machine
The main wrapper object of the library. Stores all curent instances of tween objects and drives them.

Fields:

  • instances
__tween
The base table for all tween objects.

Fields:

  • func The easing function to use for this tween.
  • v_start The starting value for the tween.
  • v_end The end value of the tween.
  • value The value between v_start and v_end representing the current tween progress.
  • start_time The time at which the tween was started, set in init() via the time() function.
  • duration The duration of time the tween should last for.
  • elapsed The amount of time elapsed since the tween was started.
  • finished A bool for whether or not the tween has finished running.
  • step_callbacks A table of registered callback functions. Called in update() after a new value has been set. Will call all registered functions with value as the argument.
  • finished_callbacks A table of registered callback functions. Called at the end of update() after the tween has been marked as finished. Will call all registered functions with self as the argument.
generated by LDoc 1.4.6 Last updated 2018-05-06 00:17:25