Page 4 of 5

Re: flux: A fast, lightweight tweening library

Posted: Thu May 22, 2014 5:55 pm
by smoking bunny
@rxi
thank you very much for that. ill have a look after ive finished some code ive been putting off ;)

Re: flux: A fast, lightweight tweening library

Posted: Thu May 22, 2014 6:42 pm
by SiENcE
You are right. It's an issue with love-loader. The finishedCallback is called twice. Now I need to find the reason.

Sorry to take your time. Thank you for the nice example. Flux is great!

Re: flux: A fast, lightweight tweening library

Posted: Thu May 22, 2014 7:59 pm
by SiENcE
So, maybe it's an love-loader problem.

Here is an sample with love-loader. Look at the console...after love-loader has loaded the image...the callback function is called twice. But without the first tween it's only called once.

Re: flux: A fast, lightweight tweening library

Posted: Fri May 23, 2014 11:14 am
by rxi
SiENcE wrote:So, maybe it's an love-loader problem.

Here is an sample with love-loader. Look at the console...after love-loader has loaded the image...the callback function is called twice. But without the first tween it's only called once.
Each :oncomplete() callback was run only once when I ran it:

Code: Select all

first tween finished
image	table: 0x00dd47b8	left-hand-climber-hi
second tween finished
I'm still not convinced flux is at fault here; let me know if I'm missing something.

Re: flux: A fast, lightweight tweening library

Posted: Sat May 24, 2014 5:14 pm
by SiENcE
hi rxi,

me again. I analyzed the problem and it might have todo with LuaJit.

I get different results when executing it several times.
Sometimes i get what you say.

Code: Select all

first tween finished
image   table: 0x02945188       left-hand-climber-hi
second tween finished
But sometimes I also get this:

Code: Select all

first tween finished
image   table: 0x02945188       left-hand-climber-hi
second tween finished
second tween finished
When I use Zerobrane Studio and start in debug mode...I get the expected result. But when I just press play, I sometimes get the second result. So I think, it has todo with love-loader, timing, threads or Luajit!?

Re: flux: A fast, lightweight tweening library

Posted: Sat May 24, 2014 7:59 pm
by rxi
SiENcE wrote:I get different results when executing it several times
I suspect that threads would be your most likely culprit if sometimes it works and sometimes it doesn't and everything else is basically identical between runs.

You may need to hit up the author of love-loader to try and work this out. I haven't touched threads in LÖVE, so I can't be of much help in that regard.

As a quick fix in the mean time you could try creating callback functions that only execute once, you can wrap your callback with lume's once() function to do this easily, or create a local boolean outside the function which the function checks before it runs. This obviously isn't an ideal fix, and may not even work if threads are the issue here.

Re: flux: A fast, lightweight tweening library

Posted: Sat May 24, 2014 8:12 pm
by SiENcE
Yeah I already wrote this in the love-loader thread.

The boolean is a good work around, but i hope love-loader could be fixed.

Thanks for your suggestions!

Re: flux: A fast, lightweight tweening library

Posted: Mon May 26, 2014 3:58 am
by Kyle
Imgur approved of your demo .gif!

Re: flux: A fast, lightweight tweening library

Posted: Sat May 31, 2014 3:01 am
by Jasoco
This library is amazing. I started using it in a new project. So much easier than writing my own tweens. So awesome.

I do wish it had some more Easing options. Like bounce.

Also, some ways of modifying parameters of the Easing functions. Like how much "over" the Elastic function goes. Or how many times it would bounce with a Bounce call.

Keep it going! So useful!

Re: flux: A fast, lightweight tweening library

Posted: Sat May 31, 2014 8:34 am
by rxi
Jasoco wrote:[...] I do wish it had some more Easing options. Like bounce.
I don't have any plans to add more easing functions to flux for the moment. You are able to add your own easing functions for your project easily though by assigning a new one to the flux.easing table.

An easing function should take a single parameter, a number between 0 and 1 which represents the tween's linear progress. It should return a value between 0 and 1 which represents the progress we actually want to be applied. For example, if we wanted to add an easing function which randomly jittered the tweened values while it was moving to the destination, we could do:

Code: Select all

  flux.easing["jitter"] = function(p)
    return p + (1 - math.random() * 2) * 0.04
  end
Then we'd use :ease("jitter") when creating our tween.

Likewise, a tween with a custom backout value could be done as follows:

Code: Select all

  local amount = 4
  flux.easing["backout2"] = function(p)
    p = 1 - p
    return 1 - (p * p * ((2 + amount) * p - (1 + amount)))
  end