-
Notifications
You must be signed in to change notification settings - Fork 26
Getting Started
tavuntu edited this page Jan 9, 2017
·
19 revisions
Let's create a button with an event. X and Y coordinates are 10 and 10 by default, width and height fit the text:
require "gooi"
function love.load()
gooi.newButton("Exit"):onRelease(function()
love.event.quit()
end)
end
function love.draw()
gooi.draw()
end
function love.mousepressed(x, y, button) gooi.pressed() end
function love.mousereleased(x, y, button) gooi.released() end
-- Use these for Android:
--[[
function love.touchpressed(id, x, y) gooi.pressed(id, x, y) end
function love.touchreleased(id, x, y) gooi.released(id, x, y) end
function love.touchmoved(id, x, y) gooi.moved(id, x, y) end
]]
Result:
require "gooi"
function love.load()
gooi.newButton({
text = "Exit",
x = 100,
y = 100,
w = 150,
h = 35,
align = "left"
}):onRelease(function()
gooi.confirm("Are you sure?", function()
love.event.quit()
end)
end)
:bg("#FFFF00")-- yellow
:fg({0, 0, 0})-- black
:setRadius(6)-- corner radius
:border(3, "#FF8800")-- 3 pixels width, orange
end
function love.draw()
gooi.draw()
end
function love.mousepressed(x, y, button) gooi.pressed() end
function love.mousereleased(x, y, button) gooi.released() end
Result:
require "gooi"
function love.load()
btn = gooi.newButton({
text = "Exit",
x = 100,
y = 100,
w = 150,
h = 35,
align = "left"
}):onRelease(function()
gooi.confirm("Are you sure?", function()
love.event.quit()
end)
end)
:bg("#FFFF00")-- yellow
:fg({0, 0, 0})-- black
:setRadius(6)-- corner radius
:border(3, "#FF8800")-- 3 pixels width, orange
slider = gooi.newSlider(1)-- move it to change from yellow to red
end
function love.update(dt)
gooi.update(dt)
btn:bg({255, slider:getValue() * 255, 0})
end
function love.draw()
gooi.draw()
end
function love.mousepressed(x, y, button) gooi.pressed() end
function love.mousereleased(x, y, button) gooi.released() end