Skip to content
/ soft Public

var = value ---> var:to(value) - Allows for smooth transitions when assigning variables

License

Notifications You must be signed in to change notification settings

Ulydev/soft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

soft

soft is a LÖVE library that replaces normal variable assigning (var = value) with smooth lerping ( var:to(value) ).

Setup

local soft = require "soft" --require the library

Usage

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

Methods

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()

About

var = value ---> var:to(value) - Allows for smooth transitions when assigning variables

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages