A simple library for creating buttons with LÖVE 2D.
This project is not finished yet so you may encounter some bugs !
- Execute function on click
- Can easily remove buttons with
button:delete()
- You can easily modify the code ! (because it is very lite)
- First step, require the librarie :
button = require "button.lua"
- Second step, adding
button:new()
tolove.load()
,button:update(dt)
tolove.update(dt)
andbutton:draw()
tolove.draw()
.
function love.load()
button:new(--Put your button here)
end
function love.update(dt)
button:update(dt)
end
function love.draw()
button:draw()
end
- Third step, create your button in
love.load()
like this:
ExampleButton = {button:new(300, 150,150,100,{1,1,1}, "Example", {0,0,0}, function()print("Example")end, false)}
DONT FORGET !!! -> YOUR BUTTON IS A TABLE WITH THE button:new()
INSIDE.
You can check the example
folder to see an example LÖVE2D project with the librarie.
- How to use the
button:delete()
function:
button:delete(ExampleButton)