This is my “main” structure
and this is my code to load/unload “scenes”
function init(self)
self.current_proxy = "menu#menu"
msg.post(self.current_proxy, "load")
end
function on_message(self, message_id, message, sender)
if message_id == hash("proxy_loaded") then
-- New world is loaded. Init and enable it.
msg.post(sender, "init")
msg.post(sender, "enable")
msg.post(sender, "acquire_input_focus")
print("proxy_loaded", sender)
elseif message_id == hash("pause_game") then
msg.post(self.current_proxy, "set_time_step", {factor = 0, mode = 1})
elseif message_id == hash("change_proxy") then
msg.post(self.current_proxy,"unload")
if message.proxy == "" then
print("reset proxy")
else
self.current_proxy = message.proxy
end
elseif message_id == hash("proxy_unloaded") then
print("proxy_unloaded", sender)
msg.post(sender, "release_input_focus")
msg.post(self.current_proxy, "load")
end
end
to change the scene or reset the level I send a message:
example for Menu button in level complete:
msg.post("main:/levels#level_controler", "change_proxy", {proxy = "menu#menu"})
- I am using the correct method?
- for reset the level I unload and load the same proxy
- how can make a fade transition? maybe with gameobject and go.animate the alpha? I need a sprite size of 1280x720.
Sorry for my english.