Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Loading Screen?

Author
Message
ABCProgrammer
8
Years of Service
User Offline
Joined: 21st Jul 2015
Location:
Posted: 25th Jul 2017 13:39
How do I implement a loading screen in AGK2 Basic?

This is I want all relevant files to be loaded into the memory and while it is doing this it should show a progress bar.
Fluorescent
FPSC Reloaded TGC Backer
18
Years of Service
User Offline
Joined: 1st Aug 2005
Location: Stockholm, Sweden
Posted: 29th Jul 2017 18:26
The way I've done it right now is and without a progressbar, is that I've created a sprite that is one of those loading spinners. I position it and call PlaySprite so it animates. Then in my loop where I load all the leveldata and do initial calculations of said data, I make sure to call Sync. This way the loading animation is run.

The easiest way to show a progress bar would probably be to create a sprite, set the width to 0. Then you first figure out how much you need to load, perhaps by counting the number of files or similar. Then you create a loop to load all these files and in every iteration you increase the width of the progressbar sprite. Then call Sync. That should work.
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 12th Oct 2017 00:58 Edited at: 12th Oct 2017 01:06
Quote: "The easiest way to show a progress bar would probably be to create a sprite, set the width to 0. Then you first figure out how much you need to load, perhaps by counting the number of files or similar. Then you create a loop to load all these files and in every iteration you increase the width of the progressbar sprite. Then call Sync. That should work."


That is what I did recently, and made the full bar 225 pixels wide.

Then I loaded a music file first as OGG that was 75 seconds, which was long enough to load all my assets plus extra time.

I use a do-loop right before the main loop, and I set the width of the bar based on the duration of the song, where each second passed add 3 pixels to the width.

The assets usually load in less than a minute even on a slow processor, so I had extra time to spare. (use a shorter music file for faster load times)

The user never knows about waiting the extra 15+ seconds, they just see a steady moving progress bar as the song plays.

Once the 75 seconds is reached the bar is filled and then I exit that loading loop and go to the main one and the game begins.

That way, I don't have to worry about keeping track of which assets have loaded, or have a bar that moves at various speeds.

I also change the info screen shot every X seconds based on the duration of the song and everything runs really smooth.

I am using AGK2 tier 1 also.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2024-04-24 21:17:06
Your offset time is: 2024-04-24 21:17:06