Page 1 of 1

scene transitions with hump

Posted: Wed May 18, 2016 9:02 pm
by ozergul
Hi,
I wanna make scene system. I searched and found hump and now i am using gamestate of hump. it is good.

but there is a problem, in scene transitions, old scene does not disappear.

how can i achieve this..

Code: Select all

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

Re: scene transitions with hump

Posted: Wed May 18, 2016 10:20 pm
by Sulunia
You mean things do not disappear from screen?
So, the scene is not changing?

Re: scene transitions with hump

Posted: Wed May 18, 2016 10:36 pm
by ozergul
Sulunia wrote:You mean things do not disappear from screen?
So, the scene is not changing?
scene is changing, but each click, objects come over and over.

i fix the problem using another gui library called suit.

Re: scene transitions with hump

Posted: Mon May 30, 2016 8:42 pm
by Goats!
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.

Here is an example:

Code: Select all

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
Hope this helps! :)