Layout pre-load

Get help using Construct 2

Post » Mon Apr 24, 2017 9:26 am

I have quite a big layout, and its loading takes a long time. Is there a way to load it before a player enters it? Maybe I can make a kind of loader layout, but inside the game? Or some dynamic loading like in 3d games, when it renders only the visible part of the world? Is it possible?
B
5
Posts: 13
Reputation: 251

Post » Mon Apr 24, 2017 12:08 pm

This might work (no guarantees though - haven't tested it!):

Create a new layer called "loader" above all the other layers.
Add a tiled background that covers the entire window and a sprite with a loading animation to the layer.

Add a global called lastObjectCount.

We can now use the system expression"objectcount" to check how many objects have been loaded in:

Every X seconds if lastObjectCount < objectcount, set lastObjectCount to objectcount
Else set layer "loader" invisible (and start the level, activate the player character etc)

Adjust the X seconds to find a value that doesn't trigger incorrectly.

Like I said, just guessing so could be a load of old rubbish - apologies in advance if that's the case!
B
19
S
8
G
3
Posts: 429
Reputation: 3,972

Post » Mon Apr 24, 2017 3:17 pm

@mekonbekon, all this actions are running before the layout starts, as I guess
Layout will not start before all the objects are ready and all "On the start of layout" events are done
If it takes much time, there would be just a black screen, which I'm trying to avoid
B
5
Posts: 13
Reputation: 251

Post » Mon Apr 24, 2017 4:26 pm

@Romalex360 ah, fair point. I'll have a think about it and let you know if I come up with a different solution.
B
19
S
8
G
3
Posts: 429
Reputation: 3,972

Post » Mon Apr 24, 2017 4:41 pm

Romalex360 wrote: Or some dynamic loading like in 3d games, when it renders only the visible part of the world? Is it possible?


that's what you'd use different layouts for... cut up your current large layout and spread it over multiple ones that use the same event sheet. You will need something to hide the load time, but it should be a lot shorter if you make each layout more manageable. But if you want it seamless, not sure if that's the way to go.

what is your average object count at startup? how about mem usage?
B
97
S
32
G
15
Posts: 1,198
Reputation: 16,178

Post » Mon Apr 24, 2017 7:07 pm

@jobel
Yeah, layout should be seamless
It's a kind of top-down action game, but I use random terrain generation here, which uses a lot of CPU
Layout size is about 5k filled by 32×32 tiles
Algorithm also makes invisible walls on some slopes

Well, the main problem are this calculations
They can take a long time, it's ok, but I want the main problem is that i can't track it and hardwired to the start of thus layout
For example, I can't fill the tilemap from another layout, because then it will reset
So I want to make all calculations and load the layout in memory before it starts, without this long black pause on the transition
B
5
Posts: 13
Reputation: 251

Post » Mon Apr 24, 2017 8:07 pm

You can make a loader layout of sorts, I haven't tried it yet myself though.

Sprites are kept in memory if they are in use on both the previous layout and next layout.

You can take advantage of this by using the load from url action to preload assets gradually in an intermediate loader layout.

This is mostly useful to prevent the "freezing" that occurs between layout when loading large amounts of sprites into memory. I'm not sure if this would help you regarding cpu use on start of layout if you're dynamically placing your terrain on start of layout.

Are you generating the entire map in a single loop/frame? Maybe you can break it up into multiple frames by using a counter. Start by generating what can immediately be seen, and let the rest of the map generate over time.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Thu Apr 27, 2017 8:16 pm

@oosyrag could you possibly expand on your reply? I have been trying to find a solution to this issue, but without any success. You
can see what I tried here: viewtopic.php?f=147&t=191033&p=1118910&hilit=pre+load#p1118910

Hope you can possibly help.

Thanks
B
10
S
3
Posts: 87
Reputation: 957


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], brunopalermo, Nicolas951 and 14 guests