Page 1 of 2

Using easing equations

Posted: Sun Jun 07, 2009 9:57 pm
by paclito
I've see on the envy framework a lua file that has catch my attention
anim.lua

here there are some functs to move objetcs around the screen, with this demo i'm been trying to make it work, I'll add some more examples when I understand the how to function of all of them.

firs lineal moves..... next angular moves etc etc...

Re: Using easing equations

Posted: Thu Jun 11, 2009 3:28 am
by NextPivMaster
This will be very helpful in my next project, but I can't get the source files. I rename the .love to .zip but WinRAR wouldn't extract it. Could you put the sources in a zip please, this will make alot of peoples games look awsome. Good work.

Re: Using easing equations

Posted: Thu Jun 11, 2009 1:16 pm
by paclito
offcourse

there is the source and the second version of the program... all for you :-)

Re: Using easing equations

Posted: Thu Jun 11, 2009 3:33 pm
by NextPivMaster
Oh yay! I Love you(pun intended)! I'm making an animation program, it's going to use tweening, and I wanted to have a easing option, letting the animator have more realistic movements in the final product. This is going to help me so much.

Re: Using easing equations

Posted: Thu Jun 11, 2009 8:33 pm
by ljdp
These functions are definitely helpful.
However I don't like how everything is based on strings.
So I edited anim.lua to be more class based.
anim.lua
Anim, class based.
(8.59 KiB) Downloaded 347 times

Code: Select all

function anim.create( from, to, time, delay, eq, ... )
function anim:start()
function anim:pause()
function anim:callback( delay, func, ... )
function anim:update()
function anim.updateAll()
function anim:get( default )
function anim:destination()
function anim:remove()

--example
buttonanim = anim.create( -200, 60, 0.5, 1, ANIM_QUAD_INOUT )
buttonanim:callback( 0.8, function() love.audio.play( menu.sound_whoosh ) end)
buttonanim:start()

Re: Using easing equations

Posted: Thu Jun 11, 2009 10:00 pm
by paclito
arghhhhhhhhh superb!!!

please, can you make a example of this? and explain how the callback work?

please please :-)

It was the next step of the my code but you are the best

thanks thanks thanks ...

and thanks

EDIT: I haven't see the example sorry........ but perhaps you can add an example to the love file isn't?

Re: Using easing equations

Posted: Thu Jun 11, 2009 10:29 pm
by ljdp
Well I used the edited version in my parametric examples for the menu
http://love2d.org/forum/viewtopic.php?f=5&t=767
it's in menu.lua, but the code is a bit messy at the moment.

I might add an example to the moves lua, but it's not really that much different from the original.
Instead of remembering the string you just use the variable returned by anim.create()

Re: Using easing equations

Posted: Fri Jun 12, 2009 2:34 pm
by Jake
ljdp wrote:These functions are definitely helpful.
However I don't like how everything is based on strings.
So I edited anim.lua to be more class based.
anim.lua

Code: Select all

function anim.create( from, to, time, delay, eq, ... )
function anim:start()
function anim:pause()
function anim:callback( delay, func, ... )
function anim:update()
function anim.updateAll()
function anim:get( default )
function anim:destination()
function anim:remove()

--example
buttonanim = anim.create( -200, 60, 0.5, 1, ANIM_QUAD_INOUT )
buttonanim:callback( 0.8, function() love.audio.play( menu.sound_whoosh ) end)
buttonanim:start()
Oh hey that's cool. When I originally wrote this I deliberately made them use strings so I didn't have to manually store the variables myself.

Re: Using easing equations

Posted: Fri Jun 12, 2009 5:37 pm
by ljdp
I always prefer using a class based system because I would have ending up storing the strings to variables anyway so you end up using more space (although probably negligable). To each his own :monocle:

Re: Using easing equations

Posted: Fri Jun 12, 2009 5:43 pm
by bartbes
I wonder which classes are used, as I see a lot of differences on these forums, I myself always use my own system (on the wiki, called SECS). There have been discussion about this on IRC, and we came to the conclusion we should all create (and use) libraries that conform to a certain syntax, to make them interchangeable (or at least, easier to switch).