flux: A fast, lightweight tweening library

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
smoking bunny
Citizen
Posts: 67
Joined: Wed May 07, 2014 9:04 am
Contact:

Re: flux: A fast, lightweight tweening library

Post by smoking bunny » Thu May 22, 2014 5:55 pm

@rxi
thank you very much for that. ill have a look after ive finished some code ive been putting off ;)
lewis lepton
------
composer | sound designer | tinkerer
smoking bunny | bandcamp | twitter | gitHub | vimeo

User avatar
SiENcE
Party member
Posts: 791
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: flux: A fast, lightweight tweening library

Post by SiENcE » Thu May 22, 2014 6:42 pm

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!

User avatar
SiENcE
Party member
Posts: 791
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: flux: A fast, lightweight tweening library

Post by SiENcE » Thu May 22, 2014 7:59 pm

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.
Attachments
oncomplete2.love
(19.24 KiB) Downloaded 110 times

rxi
Prole
Posts: 47
Joined: Sun Mar 02, 2014 10:22 pm

Re: flux: A fast, lightweight tweening library

Post by rxi » Fri May 23, 2014 11:14 am

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.

User avatar
SiENcE
Party member
Posts: 791
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: flux: A fast, lightweight tweening library

Post by SiENcE » Sat May 24, 2014 5:14 pm

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!?

rxi
Prole
Posts: 47
Joined: Sun Mar 02, 2014 10:22 pm

Re: flux: A fast, lightweight tweening library

Post by rxi » Sat May 24, 2014 7:59 pm

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.

User avatar
SiENcE
Party member
Posts: 791
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: flux: A fast, lightweight tweening library

Post by SiENcE » Sat May 24, 2014 8:12 pm

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!

Kyle
Party member
Posts: 146
Joined: Sat Mar 16, 2013 9:46 pm

Re: flux: A fast, lightweight tweening library

Post by Kyle » Mon May 26, 2014 3:58 am

Imgur approved of your demo .gif!

User avatar
Jasoco
Inner party member
Posts: 3651
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: flux: A fast, lightweight tweening library

Post by Jasoco » Sat May 31, 2014 3:01 am

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!

rxi
Prole
Posts: 47
Joined: Sun Mar 02, 2014 10:22 pm

Re: flux: A fast, lightweight tweening library

Post by rxi » Sat May 31, 2014 8:34 am

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

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests