Smoothly load several thousand objects @ start of layout?

Get help using Construct 2

Post » Sat Jun 03, 2017 2:31 pm

Before I begin to explain the premise, I have already considered doing it in small chunks in intervals or in real-time, but both of those methods will require a lot of code re-writing.

Currently, the credits screen for my project is about 7,000 characters, and I want each spritefont character to be a separate object, rather than a single block of even a line at a time. Of course, at the start of the layout, the loop that requests "credits.txt" runs 7,000 times, and the game hangs for about two seconds while it's loading. The benefit to this text file is that I can edit the credits any time in a very intuitive way inside the text file, rather than doing it line by line in the events editor. I do have a copy of the spritefont outside the layout as is normally recommended with sprites (to prevent short stutters when a sprite is created for the first time), but I don't expect it's doing much to help.

There is an excellent tutorial about creating a new "loading" layer on top of layouts so that the player doesn't see the ugliness of a game chugging along while sprites load. While that will require some tinkering to get working, I'm happy to do it. But I would love to know about any other potential options I have in forcing a layout to wait until all objects are loaded before it beings "playing."

Thank you!
B
24
S
6
G
1
Posts: 45
Reputation: 1,890

Post » Sun Jun 04, 2017 12:27 am

@Mallets

Is there a reason you want each character to be its own object? are you animating them somehow? or applying effects to each character?

I think it "freezes" for a couple seconds because of the overhead in creating 7000+ instances of the spritefont. The text file should load almost instantly. One thing you can do is load the text at the beginning of the first layout so it is available when/if you need it. Or maintain the credits in the text file, but then copy all the text into a text global variable (you have to remove carriage returns, but you can add them back at the beginning by replacing a place holder character).

If you want everything to appear at once on the credit screen you can have a sprite block out the screen while the text is being created and then hide/destroy the blocking sprite to reveal everything when it is ready.

I made a quick test to see what happens when you create 7000+ spritefonts... then added the ability to do one big spritefont instance, and paragraph by paragraph. You can try my test here: http://www.rieperts.com/games/forum/Font_Render.capx

as you can see, it takes no time at all to create one instance, or a couple dozen paragraphs. But the individual character method does take a while to complete. I added bullet behavior to the font, so that something happens when you move the mouse over the text...
Last edited by AllanR on Sun Jun 04, 2017 1:30 am, edited 1 time in total.
B
96
S
33
G
20
Posts: 438
Reputation: 17,665

Post » Sun Jun 04, 2017 12:52 am

I would use a variable as a counter to load via index with a condition that limits actions to above 50 fps.
Image ImageImage
B
169
S
50
G
173
Posts: 8,313
Reputation: 110,270


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests