Global Command: startTween
From The Official Visionaire Studio: Adventure Game Engine Wiki
Start tween on a Lua variable. The value of the variable is changed over a certain period of time from a start value to a target value. Tweens are overwritten if they are set again.
Related functions | startObjectTween |
Syntax
startTween(target, from, to, duration, easing [, repeat, reverse_repeat])
Parameters
Parameter | Type | Description |
---|---|---|
target | string | Name of the Lua variable to start tweening on. |
from | integer/float | Tween start value |
to | integer/float | Tween target value |
duration | float | Amount of time the tween takes (in milliseconds). |
easing | integer | Type of easing. See the easings enumeration (Luadocs) for all supported values. Previews for easing types can found on easings.net. |
repeat | boolean | If true the tween starts again from the beginning after reaching the target value, looping infinitely. Default value is false. |
reverse_repeat | boolean | Only applicable if "repeat" is true. If true the tween runs backwards after reaching the target value and forwards again after reaching the start value, pendulum-wise. Default value is false. |
Return values
none
Examples
Example 1: Tween the Lua variable called "myVar" linearly from its initial value of 1 to 10 over a period of 3 seconds. The current value is continuously printed to the log file.
myVar = 1
startTween("myVar", myVar, 10, 3000, easeLinearInOut)
-- Register a function which prints out the current value of "myVar" until 10 is reached
function printMyVar()
print(myVar)
if myVar >= 10 then
unregisterEventHandler("mainLoop", "printMyVar")
end
end
registerEventHandler("mainLoop", "printMyVar")