Confusion about Collection Factories/Proxies

I’ve been going through the Defold in-editor tutorials and after going through the Colorslide tutorial I’ve been left a bit confused by the Collection Proxy system and would like some clarity about how it’s used.

What I do understand is that Defold isn’t like GameMaker where there’s only one “room” loaded at a time and you swap the room at runtime to load new game worlds; instead the Bootstrap Collection is always loaded throughout the game’s life and you load collections within it for new levels/worlds, unloading them later when no longer needed. Collections can be loaded/unloaded at runtime through both Collection Factories and Collection Proxies, and the manuals seem to stress that the former is intended for groups of game objects and the latter for separate worlds/levels.

The thing that confuses me is that, to my understanding, it seems like it would be much more practical to load levels with dynamic Collection Factories than Proxies in most cases. I’ll explain why I’ve come to that conclusion, but bare in mind I haven’t tried these in practise yet:

  • Collection Proxies can’t have their Collection property be changed programmatically, and in the Colorslide tutorial you have to make a separate proxy for each level. This strikes me as being inefficient and requiring a lot of manual work for scalability.
  • Because the reference is static, I don’t see how you’d easily make a generic re-useable “level transition” object or a fast-travel system that could take you to several different possible levels.
  • Collection Factories already have asynchronous loading features, and it seems easy to code functionality to destroy all the game objects in the collection before unloading it (assuming that isn’t done by default)
  • The manual describes proxies having a “relatively large” memory footprint when loaded. I assume this isn’t the case with dynamic factories and you also don’t have to worry about giving it input focus.

What I’d like are some practical examples of how both Factories and Proxies are used, since all the example projects are single-level and never load any other worlds. I’m new to Defold so there’s a good chance I’ve ignored some important detail.

The levels created by proxies are isolated from each other and can’t introduce unwanted behaviour such as physics objects from one level interacting with physics objects from another level. Plus it gives you a separate control over collection time step (you can pause such a collection without pausing your main collection).

If you code it right you absolutely can use the factories instead. I haven’t had a need for a proxy yet, but I can imaging that some games would benefit from it.

1 Like