Easing features.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Easing features.

Post by qaisjp »

Perhaps we could replicate the following functions in LOVE.

Source: http://wiki.multitheftauto.com/wiki/Easing
fyi, onClientPreRender is almost the same as love.update and onClientRender is the same as love.draw
These are the relative functions:
http://wiki.multitheftauto.com/wiki/GetEasingValue
http://wiki.multitheftauto.com/wiki/InterpolateBetween

That software is open source, and since LOVE is open source too, you could attempt to port it, but obviously its cool to recode it from scratch (we should retain the 3D vector portion in interpolateBetween because 3D vectors could be used elsewhere, even though its 2D in LOVE)

I think it should be like this:
love.easing.getEasingValue
love.easing.interpolateBetween
and, perhaps
object = love.easing.createAnimation("easing name", ...)
object:bindToShape(shape, {settings})
object:remove()
Lua is not an acronym.
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Easing features.

Post by Santos »

tween.lua is an easing library, and it seems to have similar functions too! :) It's cool to seem them visualized on that page.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Easing features.

Post by kikito »

Yep, it has been already done, several times, with several libs, tween among them.

If you are interested in the tweening functions alone, you should check Emmanuel Oga's repo here - https://github.com/emmanueloga/easing . Tween is a nice wrapper around those functions, adding some convenience facilities, like whole table interpolation.
When I write def I mean function.
User avatar
substitute541
Party member
Posts: 484
Joined: Fri Aug 24, 2012 9:04 am
Location: Southern Leyte, Visayas, Philippines
Contact:

Re: Easing features.

Post by substitute541 »

Actually you can do this in coding. Here it is :

Code: Select all

function easing (object, dt)
object.dx = (targetX - object.x)
object.dy = (targetY - object.y)
object.vx = object.dx * easing
object.vy = object.dy * easing
object.x = object.x + object.vx * dt
object.y = object.y + object.vy * dt
end
Call the function in love.update and specify the object and deltatime

object.vx and .vy are velocities in the x and y direction, respectively. object.dx/dy are the distances from object to target.The easing value is a decimal value less than 1. targetX/Y are the coordinates of the target you want to ease to. object is the object you want to ease. Please note. Unless your making it ease to a moving target, place the following code in the love.update function to stop the easing function, since it will forever if it is left there.

Code: Select all

local distance = math.sqrt(object.dx * object.dx + object.dy * object.dy)
if distance > 1 then
easing(object, dt)
elseif distance < 1 then
object.x = targetX
object.y = targetY
end
Currently designing themes for WordPress.

Sometimes lurks around the forum.
Post Reply

Who is online

Users browsing this forum: No registered users and 198 guests