I’ve tried for a few days now to figure this out on my own to no avail. I’ve read, and reread, the chapter on Collection Proxies and scoured the forum for an answer but I could not find one. I think I’ve got a handle on collection proxies (for the most part), but I seem to be stuck on this. The main menu, level 1 and game over (when player dies ) screen all load correctly, and from the game over screen i can restart the level. When I try to go from the game over screen to the main menu, however, I get a blank screen. It seems like the game over gui unloads correctly, however the loader script (see below) does not initialize. I had it print to be sure the unload happened and it does. I do not get an error, just a blank screen. How to I get the loader script to restart to come back to the main menu? I’m not sure what I’m doing wrong and any help would be appreciated.
Here’s my setup:
main.collection
>loader [go]
>gameOver_proxy [contains game over gui and gui script]
>level01_proxy [contains level, enemies, player, scripts, etc.]
>loader.script
>mainMenu_proxy [contains main menu gui and gui script]
Loader script:
function init(self)
msg.post("#mainMenu_proxy", "load")
end
function on_message(self, message_id, message, sender)
if message_id == hash("proxy_loaded") then
msg.post(sender, "init")
msg.post(sender, "enable")
msg.post(sender, "acquire_input_focus")
self.current_proxy = sender
elseif message_id == hash("start_level01") then
msg.post(sender, "disable")
msg.post(sender, "unload")
msg.post("#level01_proxy", "load")
elseif message_id == hash("game_over") then
msg.post("#gameOver_proxy", "load")
msg.post(self.current_proxy, "disable")
elseif message_id == hash("unload_menu") then
msg.post("main:/loader#mainMenu_proxy", "unload")
elseif message_id == hash("unload_gameOver") then
msg.post("main:/loader#gameOver_proxy", "unload")
end
end
gameOver.gui script:
function init(self)
msg.post(".", "acquire_input_focus")
self.restartLevel = gui.get_node("restart")
self.mainMenu = gui.get_node("main_menu")
msg.post("main:/loader#level01_proxy", "unload")
end
function final(self)
msg.post(".", "release_input_focus")
end
function on_input(self, action_id, action)
if action.pressed and gui.pick_node(gui.get_node("restart"), action.x, action.y) then
sound.play("#sound")
gui.play_flipbook(self.restartLevel, hash("button_selected"))
msg.post("main:/loader#loader", "start_level01")
msg.post("main:/loader#loader", "unload_gameOver")
elseif action.pressed and gui.pick_node(gui.get_node("main_menu"), action.x, action.y) then
sound.play("#sound")
gui.play_flipbook(self.mainMenu, hash("button_selected"))
msg.post("main:/loader#loader", "init") -- if I replace with "main:/loader#mainMenu_proxy", "load" I still get a blank screen with no errors.
msg.post("main:/loader#loader", "unload_gameOver")
end
end