Smoothly load several thousand objects @ start of layout?

0 favourites
  • 3 posts
From the Asset Store
Progress\Loading Bar. Now Load you game like a Professional.
  • 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!

  • 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...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I would use a variable as a counter to load via index with a condition that limits actions to above 50 fps.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)