edit : my 1st message was probably messy and unclear (so nobody answered it ) because my mind was not clear itself at this moment.
Just added a 2nd message to summarize my point/question.
edit : my 1st message was probably messy and unclear (so nobody answered it ) because my mind was not clear itself at this moment.
Just added a 2nd message to summarize my point/question.
My 1st message may be pretty messy, soā¦ Iāll simplify and reformulate it:
Letās say you want to build a ābuild&fightā game (ex: clash of clans), where users will frequently switch from one scene to another (build <> fight).
Would you have
1/ 1 collection per āsceneā (1 collection for the building phase, 1 collection for the battle phaseā¦ each of them containing 1 tilemap)
or
2/ 1 collection for both (including 2 tilemapsā¦ so the loading times between each scene are faster?)
?
Are there reasons not to use the 2nd option?
I would use multiple collections and unload the other when not used, it would give better performance.
My thinking is that itās a trade-off between processing power (loading new collection) and memory (storing multiple assets in RAM).
If you are concerned about loading times, I would try to have everything in one collection.
Can you make a test of either version to get a feel for it? Make sure to use the profiler tools as well.
Having 1 collection per playable āsceneā is nice, because then one can set it as the bootstrap collection in the game, and it is easy to start and debug that particular āsceneā.
It all depends on how you like to split things up, and how much iteration you expect to do in a scene. E.g. are you developing them one after another, or both at the same time?
so the loading times between each scene are faster?
Iāve touched on this subject before.
The loading is probably going to be very fast anyways, but if this is your concern
all we can give you are good guesses. Only you will know what will actually be inside your collections.
I advice you to create a test where you switch between the two scenes, and the scenes are āfullyā implemented in terms of tilemap size, number of sprites etc.
Once you have that, you measure the time it takes to load and decide if thatās ok or not.
This is a really big advantage to this approach. It is really nice to be able to test something in isolation. But it also requires that your game is designed to handle this or that it can easily be set up like that.
Thank you for all your answers! Tons of good insights
I understand why I should have 1 collection per āgameplay sceneā, this is how I organized my project until now since itās definitely more convenient to start with a clean sheet when starting a new scene.
But still, my loading time are super long so I have to do something about thatā¦ and I know that no one can help me without knowing the project itself and how/why I made things.
Is there a way to precisely know what makes the loading time so long?
edit: (maybe I should start using the profiler )
How long?
Not really, but what you can do is to check the profiler and build report to see what the loaded collection contains. Perhaps it has some huuuge files you didnāt know about?
@britzl
Note that Iām talking about transitions between collections, not the initial loading with āDefoldā displayed (just in case)
To make it easier for you (or anyone else) to provide feedback/advice, I made 3 videos:
ā¦
In my case, a collection of a specific game mode (idlebuilder / battle) contains the tilemaps of each theme (dungeon & village), I just hide dynamically the one I donāt want to be displayed. And the user can switch from a theme to another via the debug menu.
HTML5 - DESKTOP > Theme āDungeonā
HTML5 - DESKTOP > Theme āVillageā
As you can see, for some reason the āloadingā (black screen when a collection is being loaded) is much longer with the āvillageā themeā¦ while both are supposed to be (almost) the same.
The only differences I see between ādungeonā and āvillageā themes:
1/ Tilemap size: 20x70 (dungeon) vs 20x100 (village) => 32x32 tiles for both
2/ Tilemap source image size: 640x768 (dungeon) vs 640x1024 (village)
3/ Character sprite size: 96x96 (dungeon) vs 192x128 (village)
(but the chars are spawned once the collection is loadedā¦ so no impact on the duration of the āblack screenā display right?)
Except that, this is the exact same game (they even share the same game save)
What could make such a difference in terms of loading time between the 2 themes?
The tilemap size? The tilemap source image? Both?
ā¦
ā¦
Then I decided to isolate and keep only what was necessary for the ādungeon themeā, and removed ALL unnecessary assets (including the āvillageā tilemap, but also audios, most atlases etc.)
HTML5 - MOBILE > Theme āDungeonā (āsuper pure versionā)
The initial loading (where āDefoldā is displayed) seems shorter, but the rest is pretty similar.
Why is the "battle " mode faster to load the the āidle builderā mode?
The main/only difference between both scenes is just the tilemap sizes, againā¦
20x70 (idle_builder) vs 20x30 (battle)
The other differences are what happens in the scene (tilemap construction, character spawning etc.) but it has nothing to do with the collection loading right?
.
So, in the endā¦ What makes a collection more or less fast to load?
Would you have optimization tips? (ex: tilemaps)
Also note that I use a scene_controller scene/script that is used to load/update the tilemap data (everytime I load a scene)
But since itās common to both dungeon and village themes, it probably does not explain why the idle_builder collection of the 2nd theme is much longer to load that the 1st oneā¦
Short and simple answer: The size of the assets used by the collection.
In the case where you isolate your game to a single collection with the assets, what is the size of the individual assets? Check the build report or the files in /build folder.
If you suspect the texture sizes, you should really also test the texture compression which should reduce the size of them.
You probably donāt want to have it on at all times, but just as a comparison to show what the user experience would be.
I reorganized my project so itās easier to isolate a āpure versionā.
Just rebuilt in the āpurestā conditions (no background nor audio, removed anything related to the 2nd theme etc.), and here is the report (maybe youāll be able to tell me if something looks wrong)
https://gaminho.com/perso/WIP_idle_dungeon_20220428/report.html
On mobile, the idle_builder collection still takes like ~3-4s to be loaded (black screen), why is that?
The only difference between both collections is the tilemap (but the tilemap source image is the same)
You can give it a try here:
https://gaminho.com/perso/WIP_idle_dungeon_20220428/
By texture compression, you mean that? (it was already enabled)
Note that is my case, the only āassetā present in the collection is the tilemap.
Everything else (upgrade buttons, characters etc.) is generated once the collection is loaded. There is almost nothing in the collection itself, so it should load instantly shouldnāt it? (and then update the tilemap, spawn the charactersā¦ I would accept that it can be laggy, but I should be able to see it being laggy - the black screen should not be there)
Could it come from what is performed before loading the collection with monarch? (in the scene_controller script, where I dynamically load the tilemap data and put them into tables etc.)
Probably not butā¦ well, I donāt know :o . . .
Good question. According to the build report thereās not much in the collection that could explain it. It looks like a 2k texture plus some other much smaller files.
What if you start with this collection as a bootstrap collection?
Are you doing heavy stuff in the init() function any script in the collection?
For now, everything explodes since itās not designed to be bootstrapped (some required stuff is initialized in the scene_controller scriptā¦ easier this way since I couldnāt control the initialization order in the gameplay colllections)
But maybe I can tweak it to run some tests.
Yeah, I create/fill many grids, tables etc. in a few scripts (some of them being shared with the battle collection, but not all of them)
Would you recommend moving this stuff from the init() to the update() (1st frame) ?
Enabling it is one thing, configuring it is the main part.
Are you sure your atlas is compressed?
Youāll see which configuration is used in the top left corner when you have the atlas open.
Thanks!
I quickly configured the texture compression and used a common ādefaultā setting (the possibility to have a unique configuration for each type of asset is cool though).
It seems to work as intended for all elements (assets contained in atlases appear more or less blurry, depending on their atlas size etc.) exceptā¦ the tilemap source image.
I even entered the path of the image itself (3rd line in path settings) butā¦ still nothing
Did I miss something? is there something specific to know about tilemap source image compression?
Have you set the texture profile in game.project?
A quick test for me show that itās possible to enable texture profiles for a tile source:
And then you verify it like so: