Re: flux: A fast, lightweight tweening library
Posted: Tue Jun 03, 2014 6:31 pm
Hey rxi,
First, I just want to say, this is a phonomenal library. I did however run into one difficulty (which I've resolved) that I thought should perhaps be addressed in the library itself. The source of my trouble seems to be the inability to check if tweens are applied to an object (and how many).
Maybe some code will clarify. I had to write the following function:
This allowed me to respond to user input and either create a new tween chain, or add to an existing one, as appropriate. Basically, I don't know if the user is making additional moves (asking for more tweens) before the previous tweens are complete, or after.
I feel like I'm explaining this badly. See the attached love file.
Also, there may be entirely different ways (easier and more sensible ways even) of solving this issue. I just know that none of the more simplistic paths I explored worked.
First, I just want to say, this is a phonomenal library. I did however run into one difficulty (which I've resolved) that I thought should perhaps be addressed in the library itself. The source of my trouble seems to be the inability to check if tweens are applied to an object (and how many).
Maybe some code will clarify. I had to write the following function:
Code: Select all
function tweenit(obj, vars)
obj.tc = obj.tc + 1
if obj.tween == nil then
obj.tween = flux.to(obj, 0.2, vars)
:ease("linear"):oncomplete(
function()
obj.tc = obj.tc - 1
if obj.tc == 0 then
obj.tween = nil
end
end)
else
obj.tween = obj.tween:after(obj, 0.2, vars)
:ease("linear"):oncomplete(
function()
obj.tc = obj.tc - 1
if obj.tc == 0 then
obj.tween = nil
end
end)
end
end
I feel like I'm explaining this badly. See the attached love file.
Also, there may be entirely different ways (easier and more sensible ways even) of solving this issue. I just know that none of the more simplistic paths I explored worked.