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()
Easing features.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Easing features.
Lua is not an acronym.
Re: Easing features.
tween.lua is an easing library, and it seems to have similar functions too! It's cool to seem them visualized on that page.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Easing features.
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.
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.
- substitute541
- Party member
- Posts: 484
- Joined: Fri Aug 24, 2012 9:04 am
- Location: Southern Leyte, Visayas, Philippines
- Contact:
Re: Easing features.
Actually you can do this in coding. Here it is :
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
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
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.
Sometimes lurks around the forum.
Who is online
Users browsing this forum: No registered users and 198 guests