Collection loading

Collection loading in Defold is a complete mess. I want to make a starting splash screen. I have been trying for 2 days now but can’t get it right. I can load the game after the splash screen, but I can’t unload the splash screen. It just stays there as a gui on the game collection. Please, help!
Here’s my code:

function on_input(self, action_id, action)
	if action_id == hash("fire") then
		msg.post("#loaderproxy", "load")
		msg.post("#splashproxy", "unload")
	end
end

And here’s the error message:
Component ‘/loader#splashproxy’ could not be found when dispatching message ‘unload’ sent from default:/loader#loaderScript

It all comes down to understanding the messaging system. I’d be happy to take a look at your project if you wish to share it.

Did you check this example:

I also have a similar example here:

3 Likes

It’s worth reading what @britzl has posted to understand messaging.

You can always do print(msg.url()) to print the exact path of a script, which will give you a better idea of the proxy component too.

if action_id == hash(“fire”) then

I doubt it’s related to any problem you’re seeing at the moment, but you should add action.pressed to limit the action to only once for testing like this.

if action_id == hash("fire") and action.pressed then

On the topic of screen management, Monarch makes screen loading convenient and easy. There’s a few concepts you need to learn to use it, such as making sure the collection names are unique in their property panel (not referring to file names).

2 Likes

Dear britzl,
here’s my project in its current state:
https://www.icloud.com/iclouddrive/0cV7Zbg27MxoXUEWFI1Ggpdvw#Bomber

I’m trying to make a splash screen. I made it into a separate collection and load it as bootloader. Then from this splash screen collection I load the main collection of the game. Loading works, but the splash screen collection stays there as an axtra layer on the main collection. Note that the splash screen collection contains a gui gameobject, if it makes any difference.

Thank you!

Ok, I kinda solved it:
I added a go.delete() function with the id of the gui of the splash collection.
This feels like a half solution: the splash gui isn’t visible anymore, but the collection isn’t unloaded. Whatever I add to the splash screen, I have to go.delete() them one by one in this way.

I’m only able to add this project to an iCloud account. Could you instead provide a link to a downloadable zip file? If you remove the build, .git and .internal folder from your project and zip it it should be small enough to share here.

https://www.icloud.com/iclouddrive/0B-UbIVTI2X5bM4NFA2TQGU0A#Bomber
Ok, now it’s in one zip file, that way you can download it. Icloud only lets single files to be downloadad, sorry, I forgot about it.
So now my game has a splashscreen and if you press space the main collection is loaded and the splash disappears. But it only disappears because its corresponding go is deleted . Unloading the collection just doesn’t work.

Unloading the splash screen collection doesn’t work because you’re loading it as the bootstrap collection, not as a proxy.

2 Likes

@Potota is correct. The bootstrap collection can’t be unloaded. Delete the splash screen using go.delete when it is no longer needed

2 Likes

Vow! That’s exactly the solution I ended up with by myself after 2 days! Thank you guys, the developers are really helpful here! I’ll go on making my project.

3 Likes