flux: A fast, lightweight tweening library
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: flux: A fast, lightweight tweening library
Totaly missed that, sorry
Thanks
Thanks
- smoking bunny
- Citizen
- Posts: 67
- Joined: Wed May 07, 2014 9:04 am
- Contact:
Re: flux: A fast, lightweight tweening library
thanks for this library. very useful. im just working with timers and fancy using tweens instead of 'dt'
graci
graci
lewis lepton
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
Re: flux: A fast, lightweight tweening library
You've got a great library, you just need a better marketing department. Sweet mother of gifkikito wrote:This library is really nagging me to update tween.lua.
But I must resist. Not ... yet.
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: flux: A fast, lightweight tweening library
Well, I do consider the name kikito as a quality brand, speaking about code.Lap wrote:You've got a great library, you just need a better marketing department. Sweet mother of gif
Along with some other names.
- smoking bunny
- Citizen
- Posts: 67
- Joined: Wed May 07, 2014 9:04 am
- Contact:
Re: flux: A fast, lightweight tweening library
hola,
its great this library, and has taken away some 9 lines of other timer code i drummed up, so thats always good. plus easier for multiple instances.
though im finding it hard to find, but is there a 'loop' type of function. im guess its just an if statement, but have tried a few of the 'what i think they would be', but no.
say
if so, would it be possible to have a function like that.
say at the end of a tween, something like this
just an idea. but would love to know some looping function. say 'loop(1)' would mean on, 'loop(0)' would mean off. as an example
cheers
its great this library, and has taken away some 9 lines of other timer code i drummed up, so thats always good. plus easier for multiple instances.
though im finding it hard to find, but is there a 'loop' type of function. im guess its just an if statement, but have tried a few of the 'what i think they would be', but no.
say
Code: Select all
if tween == 0 then
--- some creation code---
tween = 6 --- for the reset back to 6
end
say at the end of a tween, something like this
Code: Select all
tween.to(enemyCircleCount, 0, { count = 6 }):ease("linear")
:after(enemyCircleCount, 0, { count = 0 }):ease("linear"):loop(1)
cheers
lewis lepton
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
Re: flux: A fast, lightweight tweening library
The :loop() function is something that was suggested before, but unfortunately adding it in would increase the complexity of flux by quite a bit, and would require a reworking of how everything works internally.smoking bunny wrote:[...] though im finding it hard to find, but is there a 'loop' type of functions [...]
Fortunately there is a means of looping a sequence by using the ncomplete() function. You simply create a function which initialises your tweens, and on the last tween's ncomplete() you call the function again. I've attached a small example file showing a sequence repeated 4 times using this technique, code is below:
Code: Select all
local flux = require "flux"
function love.load()
circle = { x = 400, y = 300, size = 0, color = { 255, 255, 255 } }
-- Do looped tween sequence 4 times
local count = 4
local function sequence()
-- Abort if we hit our repeat limit
count = count - 1 -- Omit this to repeat forever
if count == 0 then return end -- and this
-- Do tween
flux.to(circle, 2, { size = 100 }):ease("elasticout")
:after(circle.color, 1, { 255, 0, 0 })
:after(circle.color, 1, { 0, 255, 0 })
:after(circle.color, 1, { 0, 0, 255 })
:after(circle, 1, { size = 0 }):ease("quadin")
:oncomplete(sequence) -- Intialise the next iteration of the sequence
end
-- Intialise the first iteration of the sequence
sequence()
end
function love.update(dt)
flux.update(dt)
end
function love.draw()
love.graphics.setColor(unpack(circle.color))
love.graphics.circle("fill", circle.x, circle.y, circle.size)
end
- Attachments
-
- tween_loop_example.love
- An example of looping a tween sequence
- (2.22 KiB) Downloaded 234 times
- smoking bunny
- Citizen
- Posts: 67
- Joined: Wed May 07, 2014 9:04 am
- Contact:
Re: flux: A fast, lightweight tweening library
@rxi
brilliant, thanks a bunch.
i did see and look up oncomplete, but was just unsure of 'how' to implement it.
agree that the loop feature would be a bitch to implement. but if you do, im 100% for it. but if not, then fair enough.
thanks again
#edit
also, it does work as well. brilliant. thanks
brilliant, thanks a bunch.
i did see and look up oncomplete, but was just unsure of 'how' to implement it.
agree that the loop feature would be a bitch to implement. but if you do, im 100% for it. but if not, then fair enough.
thanks again
#edit
also, it does work as well. brilliant. thanks
lewis lepton
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
- smoking bunny
- Citizen
- Posts: 67
- Joined: Wed May 07, 2014 9:04 am
- Contact:
Re: flux: A fast, lightweight tweening library
actually, have one last thing to round it all up, which is just that, rounding the numbers.
how could i go about this. i have done the one with lua
would this be the same with rounding flux numbers? i have tried the same thing, but its not working.
how could i go about this. i have done the one with lua
Code: Select all
if enemyCountDown == 0 then
return math.floor (enemyCountDown + 0.5)
end
lewis lepton
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo
Re: flux: A fast, lightweight tweening library
I have a question.
onComplete is called everytime a tween ends. Now, how do I know when all of the tweens has ended?
In my example "self:gotoState( nextscene )" is called twice, which is no good.
It should fadein, oncomplete should call love-loader and when love-loader is finished it calls flux for fadeout. After fadeout flux calls goto next State.
onComplete is called everytime a tween ends. Now, how do I know when all of the tweens has ended?
In my example "self:gotoState( nextscene )" is called twice, which is no good.
It should fadein, oncomplete should call love-loader and when love-loader is finished it calls flux for fadeout. After fadeout flux calls goto next State.
Code: Select all
flux.to(self.fadein, 0.35, { alpha = 1 }):ease('linear'):oncomplete(
function()
loader.start(
function()
flux.to(self.fadein, 0.35, { alpha = 0 }):ease('linear'):oncomplete(
function()
self:gotoState( nextscene )
end
)
end
, print)
end
)
Re: flux: A fast, lightweight tweening library
Assuming you meant that you want flux to round the number it sets, you can do this using the nupdate function to set the tween value to the rounded value with each update:smoking bunny wrote:actually, have one last thing to round it all up, which is just that, rounding the numbers. [...]
Code: Select all
local t = { n = 0 }
flux.to(t, 10, { n = 100 })
:onupdate(
function()
t.n = math.floor(t.n + .5) -- Round .n after the tween changes it
end)
I'm a little confused what the issue is -- Are you sure its an issue with flux and not an issue with loader.start() calling the function you passed to it twice?SiENcE wrote:I have a question.
onComplete is called everytime a tween ends. Now, how do I know when all of the tweens has ended?
In my example "self:gotoState( nextscene )" is called twice, which is no good.
It should fadein, oncomplete should call love-loader and when love-loader is finished it calls flux for fadeout. After fadeout flux calls goto next State.
[...]
I made a small example showing ncomplete() not being called twice:
Code: Select all
local flux = require "flux"
function love.load()
circle = { x = 400, y = 300, size = 0, color = { 255, 255, 255 } }
text = ""
local function output(str) text = text .. str .. "\n" end
flux.to(circle, 3, { size = 100 }):ease("expoout")
:oncomplete(
function()
output("first tween finished")
flux.to(circle, 3, { size = 0 }):ease("expoin")
:oncomplete(
function()
output("second tween finished")
end)
end)
end
function love.update(dt)
flux.update(dt)
end
function love.draw()
love.graphics.setColor(unpack(circle.color))
love.graphics.circle("fill", circle.x, circle.y, circle.size)
love.graphics.print(text, 20, 20)
end
- Attachments
-
- oncomplete.love
- (2.12 KiB) Downloaded 198 times
Who is online
Users browsing this forum: No registered users and 5 guests