rxi / flux Goto Github PK
View Code? Open in Web Editor NEWA fast, lightweight tweening library for Lua
License: MIT License
A fast, lightweight tweening library for Lua
License: MIT License
Sometimes I want to make chains of tweens, like so
local f = flux.to(...)
f = f:after(...)
f = f:after(...)
this works pretty nice, except for the fact that the callsite for the first tween is different from the other tweens. this can be inconvenient, for example, when doing this in a loop:
local f
for _, obj in ipairs(objects) do
if not f then
f = flux.to(...)
else
f = f:after(...)
end
end
I'm wondering if it's possible to move this logic up, so for example there could be a flux:after() method that, because it's called on the flux object and not a tween object, behaves like flux.to(). that would look like this in a loop:
local f = flux
for _, obj in ipairs(objects) do
f = f:after(...)
end
I'm not sure if this is a bug,an intended feature, or an error on my part, but I felt it'd be worth posting regardless.
Whenever you have a tween inside of an iteration and try to pass the iterator as an argument to the function within :oncomplete, it gives the error "expected function or callable". A (barebones) example of what I'm attempting to do is below:
for i, player in ipairs(playerList) do
flux.to(player, moveSpeed, {x =xvalue, y = yvalue}):delay(.5):oncomplete(resetAction(player))
end
A temporary solution I've found is that by calling a mediating function with :oncomplete to then call the main function with the arguments, you can get by without an issue.
If you'd like more code to find the issue, I can provide it as soon as possible.
Huge fan of this library! One issue/question:
If I chain together multiple tweens in one line of code using flux.to(...):after(...):after(...) and call tween:stop(), it appears that the first tween is stopped and removed from flux.tweens but the others remain and carry out their operations.
Is this the intended behavior? Is there a preferred method for interrupting multiple tweens this way? For the moment I'm having to use oncomplete() for each new tween so I can safely interrupt any complex events.
Thanks!
Is there a possibility to check whether a tween is active or not? Do I have to do it with :oncomplete
? Or can I manually check it if I store the tween as a variable like this:
myTween=flux.to(self, 4, {x=300})
...
if myTween:isActive() then
...
end
I need an OutBounce ease, is it possible to add?
It would be nice to have a repeat functionality. Something to repeat the whole transformation with options to reverse it "in time" as well.
local t = flux.to(...):after(...)
-- (after some time)
t:stop()
-- (The 'after' tween still plays if stopped before the start of the 'after' tween
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.