Loading system

Good evening,

I’m seeking for a way to create a loading system like a loading bar for example but I’ve absolutely no idea of how it works with Corona (not only Corona by the way).

I want to build such a system in order to load all the sounds that I use in my game and then avoid a freeze of 4 seconds at the beginning.

I have to first load all the sounds cause playing them and loading them at the same time causes a feeling freeze.

Any ideas ? 

Thank you. ~ Apologizes for the bad english

There are several approaches to this.

  1. Keep it simple and show a native.setActivityIndicator() when you start loading, turn it off when you’re done. It won’t show progress, but it works.

  2. Create some form of graph (usually a bar) that changes (perhaps grows in size). You could use a display.newRect() for a plain bar, load an image with display.newImageRect(), or use a widget.newProgressView. After each item that loads, update the image/widget with a new value that grows closer to 100%.

  3. Some people run in to a problem with #2 where the bar doesn’t increment. This is where “Coroutines” come in. Lua doesn’t support threading, but you can use Coroutines to do something similar. You can read about them here: Basically it’s the same as #2, but you intentionally break your loading up into smaller chunks that can release control back to the main program so it can update.

  4. Design a Loading screen, perhaps an image that covers the whole screen that says “Loading” on it. When you’re done loading, get rid of the image.

Rob

Those are great suggestions!

I’d like to add to #4. You could create an animation that is not related to the progress. A lot of software uses an arc that spins around the center of the screen. I’m a fan of games that use something related to the game, though.

There are several approaches to this.

  1. Keep it simple and show a native.setActivityIndicator() when you start loading, turn it off when you’re done. It won’t show progress, but it works.

  2. Create some form of graph (usually a bar) that changes (perhaps grows in size). You could use a display.newRect() for a plain bar, load an image with display.newImageRect(), or use a widget.newProgressView. After each item that loads, update the image/widget with a new value that grows closer to 100%.

  3. Some people run in to a problem with #2 where the bar doesn’t increment. This is where “Coroutines” come in. Lua doesn’t support threading, but you can use Coroutines to do something similar. You can read about them here: Basically it’s the same as #2, but you intentionally break your loading up into smaller chunks that can release control back to the main program so it can update.

  4. Design a Loading screen, perhaps an image that covers the whole screen that says “Loading” on it. When you’re done loading, get rid of the image.

Rob

Those are great suggestions!

I’d like to add to #4. You could create an animation that is not related to the progress. A lot of software uses an arc that spins around the center of the screen. I’m a fan of games that use something related to the game, though.