Hi, im having a issue with a level selection screen menu for a game i made. For the level selection screen the GUI node is not receiving any input and i have no idea why.
I have 3 scripts, the loader script, the main menu script and the script for my level selection menu. The main menu script works fine and the loader works as it loads the main menu and loads the level selection menu but when i press “level 1” nothing happens
function load_levelmenu(self) -- Code for my level 1
msg.post(".", "acquire_input_focus")
print("hello2") -- checking if anything happens
end
function on_input(self, action_id, action) --Loading the level
if(action_id and gui.get_node("level1")) then -- When node is selected Level starts
if(gui.pick_node(level1,action.x,action.y)) then
msg.post("loader:/go#loader", "level1")--
end
end
-- Loader script
local function load_menu(self) --Load menu collection
msg.post("go#mainmenu", "load")
msg.post("go#mainmenu", "enable")
end
local function unload_menu(self) --
msg.post("go#mainmenu","unload")
end
local function load_main(self) --This loads main collection
msg.post("go#main", "load")
msg.post("go#main", "enable")
end
local function load_levelmenu(self) ---load the level select
msg.post("go#levelmenu", "load")
msg.post("go#levelmenu", "enable")
msg.post("go#mainmenu", "disable") ----*
end
local function unload_levelmenu(self)
msg.post("go#levelmenu", "unload")
end
function init(self)
msg.post(".", "acquire_input_focus")
load_menu(self) --Loads menu when game starts
end
function on_message(self, message_id, message, sender)
if message_id == hash("level1") then
load_main(self)
unload_levelmenu(self)
end
end
function on_message(self, message_id, message, sender) ---Load actual level
if message_id == hash ("load_level") then
unload_levelmenu(self)
end
end
function on_message(self, message_id, message, sender)
if message_id == hash ("begingame") then
load_levelmenu(self)
unload_menu(self)
end
end
-- Main menu script
function init(self)
msg.post(".", "acquire_input_focus")
end
function on_input(self, action_id, action) --Loading the level
if(action_id == hash("touch") and action.released == true) then
local textBegin = gui.get_node("begingame") --
if(gui.pick_node(textBegin,action.x,action.y)) then
msg.post("loader:/go#loader", "begingame") -- starts game
print("hello")
end
end
-- exits out the game
if(action_id == hash("touch") and action.released == true) then
local textExit = gui.get_node("exitgame")
if(gui.pick_node(textExit,action.x,action.y)) then
msg.post("@system:", "exit", {code = 0}) --This exits the game
end
end
end
i have attached all 3 scripts just so you can kinda understand my code a bit more