Why is my GUI not switching scenes?

Hi, ive created a main menu to start and exit game etc, the game exits but when start is pressed, nothing happens and no error is produced. here is the code for my loader

local function load_menu(self)
	msg.post("go#menu", "load")
	msg.post("go#menu", "enable")
end

local function unload_menu(self)
	msg.post("go#menu","unload")
end

local function load_main(self)
	msg.post("go#main", "load")
	msg.post("go#main", "enable")
end

function init(self)
	msg.post(".", "acquire_input_focus")
	load_menu(self)
end

function on_message(self, message_id, message, sender)
	if message_id == hash("start") then
		unload_menu(self)
		load_main(self)
	end
end
function init(self)
	msg.post(".", "acquire_input_focus")
end
function on_input(self, action_id, action)
	if(action_id == hash("touch") and action.released == true) then
		local textBegin = gui.get_node("start1")
		if(gui.pick_node(textBegin,action.x,action.y)) then
			msg.post("loader:/go#loader", "start")
		end
	end
	if(action_id == hash("touch") and action.released == true) then
		local textExit = gui.get_node("exit1")
		if(gui.pick_node(textExit,action.x,action.y)) then
			msg.post("@system:", "exit", {code = 0})
		end
	end    
end

Please could someone help?

Wait for the proxy to finish loading before sending the enable message. The code would be something like this:

local function load_main(self)
	msg.post("go#main", "load")
end

function on_message(self, message_id, message, sender)
	if message_id == hash("start") then
		unload_menu(self)
		load_main(self)
	elseif message_id == hash("proxy_loaded") then
		msg.post(sender, "enable")
	end
end
1 Like