soft is a LÖVE library that replaces normal variable assigning (var = value) with smooth lerping ( var:to(value) ).
local soft = require "soft" --require the library
Create variable and transition it
function love.load()
x = soft:new(200) --initialize variable with value
x:to(400)
end
Update soft
function love.update(dt)
soft:update(dt)
end
Get variable
function love.draw()
love.graphics.rectangle("fill", x:get(), 100, 50, 50)
end
Update soft
soft:update(dt)
Create variable
variable = soft:new(value)
Set variable value
variable:set(value, params) --if params.reset == true, variable's target will also be set to value
v-> variable:s(value, params)
Set variable target
variable:to(value, params) --default params.speed = 5
v-> variable:t(value, params)
Set transition speed
variable:setSpeed(speed)
Get variable
variable:get(target) --if target == true, :get() will return :getTarget()
v-> variable:g(target)
variable:getTarget()
v-> variable:gt()