Log In  

Cart #41463 | 2017-06-09 | Code ▽ | Embed ▽ | Forks ▽ | License: CC4-BY-NC-SA

This is a small (257 token) tweening library. It allows you to tween any value over time, and can be extended
by supplying your own easing and lerping functions. It also allows callbacks, functions that are called when the tween has finished, letting you sequence animations and code.

quick start:

tween(player.position, "x", 64, 100, {e=pow(2)})

-- tween(object, prop_name, target_value, duration, options_table)
-- options are 
-- "e" dual in+out easing fn
-- "ei","eo" in,out easing fn
-- "f" tween callback (takes 1 argument - the object)
-- "l" lerping function, default lerp works with number values

Please check the cart code for further examples.

Advanced tips:

If you need to stop a tween, keep a reference to it (the return value of "tween") and set it's "o" prop to nil.


v 1.0 - shaved off 7 tokens, moved bbs post to "code snippets"

P#41337 2017-06-06 15:02 ( Edited 2017-06-09 15:07)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2022-10-04 19:32:06 | 0.007s | Q:12