[SOLVED] -- How exactly to use Collection proxy to load my next stage on game?..still cant do it...any help? :')

So, like what i had said in the title…can anyone teach me exactly on how to use the collection proxy in a project so that i can load my next stage whenever i finish the current stage?..

i screenshot my project explorer so you can have a better idea:

As you can see in my project explorer, i have a folder named “LEVEL” and inside of it, i put all the levels (or what i called on the second hand – “stages”) of my game…and, yeah…its not included in my MAIN folder…how can i use a collection proxy to load the next level/stage of my game whenever i complete the current stage?..where do i need to put collection proxy?..inside my main folder or inside my level folder?..can you give me a detailed explanation on how to use and implement it on a project like this?..my brain is slowly shrinking right now…i also read all the documentation to it – ( http://www.defold.com/ref/collection-proxy/ )

and also i saw some topic like this on this forum – ( Level switch (change level) ) but i cant get what exactly they do to implement it on their game…actually, this is the last BIG problem that i have encounter right now and whenever i fix it,.everything will be fine for me…so if you have some knowledge on how to use it,…can you teach me exactly how?..thanks guys and more power! :’) any help is really appreciated…

The folder structure is totally arbitrary. Put a collection proxy component in a game object in the main collection. Where you put it on disk does not matter at all (if you put it on disc, you can also create the game object in-place directly in the collection). Then set up the proxy to the level collection you want it to act proxy of and when you want the game to load the level, send the proxy component a message:

msg.post("my_proxy_object#my_collection_proxy_component", "load")

The engine will send a message back to the script that sent the message when the collection has loaded:

function on_message(self, message_id, message, sender)
        if message_id == hash("proxy_loaded") then
                -- New level is loaded. Init and enable it.
                msg.post(sender, "init")
                msg.post(sender, "enable")
                ...

@sicher oh, hello sir,…this is what i had did…

  1. I put a GO in main.collection (named it “nextlevel”)…inside nextlevel GO i’d put a collection proxy with
    id – “proxy” and as you said, i’d set up it’s collection property to “level_2.collection” … and after that i also put a script file named “script.script”

  1. inside “script.script” i’d put the following code…

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

end

  1. I put the “level1.collection” inside “main.collection” so that whenever i launch the game, it will load the level_1.collection automatically…inside “level_1.collection”, i put a GO named “finishline” and inside of it i put a collision object (it’s actually no sprite…i dont put an image on it…i only use it as a portal to level_2 whenever the character collides on it)…and also, i put another script file on it (i named it “script.script” also but it is another script file and not the one i used in main.collection)…inside of script i put the following code below:

function init(self)

self.collected = false

end

function on_message(self, message_id, message, sender)

if self.collected == false and message_id == hash(“collision_response”) then
self.collected = true
msg.post(“main:/nextlevel#proxy”, “load”)
end

end

that’s it…BUT whenever i launch the game,…ill play the level_1,…but after my character collides to the finishline GO(i know my character already collides to it coz it is not avoidable and in the properties i already set the group and mask properly)…the level_2 didn’t load on the game…i check the console and error log for any problem but its actually clear…no signs of error…is there anything that i’d missed?..if so, well can you tell me what it actually is?..thanks! :’)