require "livecode"
local Gamestate = require "gamestate"
require "gooi"
local oyun = {}
local anamenu = {}
function love.load()
Gamestate.switch(anamenu)
end
function love.mousepressed(x, y, button) gooi.pressed() end
function love.mousereleased(x, y, button) gooi.released() end
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.draw()
gooi.draw()
end
function anamenu:enter()
lbl1 = gooi.newLabel("burası ana menü", 10, 10)
btn1 = gooi.newButton("oyuna git", 220, 40, 250, 25)
:bg({255, 0, 0})
:onRelease(function()
Gamestate.switch(oyun)
end)
end
function anamenu:update(dt)
end
function anamenu:draw()
gooi.draw()
end
--------------------------------------
function oyun:enter()
pGame = gooi.newPanel(350, 10, 420, 270, "game")
pGame:add(gooi.newButton("Bomb"), "b-r")
end
function oyun:update(dt)
end
function oyun:draw()
gooi.draw()
end
All of the previous gui elements you've created still exist, regardless of what HUMP state you are in. When you call gooi:draw() in a different state, those objects are still displayed. What you need to do is remove them before you transition to another state.
You can create a table of the names of all of the elements used in one state so you can tell gooi to remove them before you transition.
function gamestate:enter()
self.gui_objects = {}
gooi.newButton("button1", "Button", 10, 10, 10, 10)
table.insert(self.gui_objects, "button1")
end
function gamestate:leave()
for k,v in pairs(self.gui_objects) do
gooi.removeComponent(v)
end
end