Mouse hover/click

This commit is contained in:
2022-05-29 19:49:59 +02:00
parent 977d2c342b
commit f793c3e17a
3 changed files with 31 additions and 21 deletions
+12 -7
View File
@@ -1,13 +1,18 @@
function stateMenu()
local items = {"play", "rules"}
local buttons = {}
local selected = 1
local buttons = {
makeButton(10, 10, 30, 6, "play",
function() setState(states.game) end,
function() selected = 1 end),
makeButton(10, 20, 30, 6, "rules",
function() setState(states.rules) end,
function() selected = 2 end)
}
function _enter()
for k,v in ipairs(items) do
local button = makeButton(10, k*10, 30, 6, v, function() printh("click") end)
add(buttons, button)
end
end
return {
@@ -19,8 +24,8 @@ function stateMenu()
end,
_draw = function()
for button in all(buttons) do
button:draw()
for k,button in ipairs(buttons) do
button:draw(selected == k)
end
end
}