scene transitions with hump

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
ozergul
Prole
Posts: 11
Joined: Sat Apr 23, 2016 8:08 am

scene transitions with hump

Post by ozergul » Wed May 18, 2016 9:02 pm

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

User avatar
Sulunia
Party member
Posts: 201
Joined: Tue Mar 22, 2016 1:10 pm
Location: SRS, Brazil

Re: scene transitions with hump

Post by Sulunia » Wed May 18, 2016 10:20 pm

You mean things do not disappear from screen?
So, the scene is not changing?
Don't check my github! It contains thousands of lines of spaghetti code in many different languages cool software! :neko:
https://github.com/Sulunia

ozergul
Prole
Posts: 11
Joined: Sat Apr 23, 2016 8:08 am

Re: scene transitions with hump

Post by ozergul » Wed May 18, 2016 10:36 pm

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.

Goats!
Prole
Posts: 2
Joined: Fri Apr 15, 2016 10:19 pm

Re: scene transitions with hump

Post by Goats! » Mon May 30, 2016 8:42 pm

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! :)

Post Reply

Who is online

Users browsing this forum: MadByte and 27 guests