Thanks.
Actually, I already did something like that. I have a main collection with a game object called loader holding the different collections (actually, scenes or screens) proxies.
I then use this script based upon documentation about proxies:
function init(self)
self.current_screen = "title"
msg.post("#" .. self.current_screen .. "_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")
end
if message_id == hash("switch_to_game") then
msg.post("#" .. self.current_screen .. "_proxy", "disable")
msg.post("#" .. self.current_screen .. "_proxy", "final")
msg.post("#" .. self.current_screen .. "_proxy", "unload")
self.current_screen = "game"
msg.post("#" .. self.current_screen .. "_proxy", "load")
end
end
As you can see, there are (for now) two proxies. One called “title_proxy” that loads at startup of the game and one called “game_proxy” that loads when the message “switch_to_game” is received. This is sent from the “title” collection when the player pushes an input.
I tried this on “on_input” function but it didn’t worked:
function on_input(self, action_id, action)
if action_id == hash("escape") then
msg.post("#" .. self.current_screen .. "_proxy", "disable")
msg.post("#" .. self.current_screen .. "_proxy", "final")
msg.post("#" .. self.current_screen .. "_proxy", "unload")
self.current_screen = "game"
msg.post("#" .. self.current_screen .. "_proxy", "load")
end
end
The problem comes from the fact that the key press sends a message each frame. It seems to hinder the loading of the collection.