Loading & Progress bar

Hi there,

So far I really love Corona, but the one thing that has become my bane over the past couple of days is trying to figure out a SIMPLE way to pre-load my graphics and have a progress bar. It was relatively easy when I did it in Flash. I’ve looked at examples that other people have provided which either don’t work at all when I try to implement them, or they involve breaking my app into four or five separate modules to do what should be a relatively simple thing.

Can someone here please take pity on stupid me and please give me a very simple, just the basics example of how to pre-load my graphics while also updating a progress bar WITHIN one module?

Failing an example, can you at least explain to me how when I load an asset, what function/method/whatever can I call that will tell me that all my assets are done loading?

Thanks,
Neal [import]uid: 139435 topic_id: 26368 reply_id: 326368[/import]

Hey Neal,

I haven’t played with this yet but it looks like it may be helpful for you; http://developer.anscamobile.com/code/load-progress-bar

Please let me know how that goes :slight_smile:

Peach [import]uid: 52491 topic_id: 26368 reply_id: 106910[/import]

Unfortunately that link is one of the things I’ve looked at before. It breaks everything up into multiple modules which, again, I don’t want to do. There has to be a clean, simple way to do this that isn’t as overly complex as what’s posted there.

[import]uid: 139435 topic_id: 26368 reply_id: 106917[/import]

Anyone have any other suggetions? Please? [import]uid: 139435 topic_id: 26368 reply_id: 107143[/import]

Here is a suggestion from a colleague;
If he is trying to load lots of images at one time, my only suggestion is to load the images in groups and update the progress bar after each group is loaded. If he has four groups, the progress bar advances 25% after each group loads. He could create a loadImage function that took a table of images. After calling the function, you then update the progress bar and then repeat.

That talks about 25% marks though you could do it with any percentage, of course. [import]uid: 52491 topic_id: 26368 reply_id: 107356[/import]

Thanks! Will give it a try. :slight_smile: [import]uid: 139435 topic_id: 26368 reply_id: 107363[/import]

I think the problem is that the screen is not updating (refreshing) while you loading lots of stuff. I am trying that way also and loading assets in groups (different laoding functions) like this:

load1()  
setProgressBar(25)  
load2()  
setProgressBar(50)  
load3()  
setProgressBar(75)  
load4()  
setProgressBar(100)  

but nothing happens while loading and only on the very end I can see my progressbar has 100% progess. [import]uid: 39634 topic_id: 26368 reply_id: 107453[/import]

Yeah, I’m having the same issue as hsardaryan. I really, really don’t like how Corona handles it’s screen update logic.

Anyone have a suggestion to force it to do an update between each? [import]uid: 139435 topic_id: 26368 reply_id: 107687[/import]

So I found a workaround here for the “not doing anything on the screen” until the very end. What you have to do – and this is pretty counter-intuitive – is actually DELAY each of the calls in order to get each thing drawn. So to use your example above hsardaryan, we’d do this:
timer.performWithDelay(200, load1)
setProgressBar(25)
timer.performWithDelay(500, load2)
setProgressBar(50)
timer.performWithDelay(800, load3 )
load3()

etc.

Note that I’m incrementing the delay with each, otherwise all the calls end up being made at the same time, and you end up with the same problem we had before, i.e. the bar not updating until the end.

Truly wish there was a more elegant way to do this that was actually built into the environment. This is a monumental hack to make something so basic work.

Peach, thanks to you and your colleague for getting our feet on the right track here. [import]uid: 139435 topic_id: 26368 reply_id: 107751[/import]

@neal97 I didn’t checked your example yet, but anyway I don’t know how long each loadN() function will take, it depends on a lot of things, from overall iOS load at that time to device capabilities etc… means I can’t pre-guess delays for timer.performWithDelay [import]uid: 39634 topic_id: 26368 reply_id: 107846[/import]

This would be a perfect time for either some exotic runtime function or Beebe’s proxy module, actually. What you need to do is have the loadN() functions report a certain level of progress, so for example if you had the proxy module going it would be pretty simple to write a property update function that just does an incremental progress bar update.

(Runtime can do the same thing but you’re obviously spamming per frame rather than making one call, which can get a little messy) [import]uid: 41884 topic_id: 26368 reply_id: 107969[/import]

Skipping to the bottom (if someone said this before then nanny nanny boo boo stick your head in doo doo)
I do delays, and oncompletes. So basically loading something, and then on complete start the next one. I add another delay in the middle (like 100ms) as I found that sometimes I get a black screen. So I pad it and that works fine.

It’s no frills and works fine. It’s basically a “fake” way to do it.

weeeeeee

ng

*edit

So I just read what neal97 said, ya what he’s saying works.

weeeeeee! [import]uid: 61600 topic_id: 26368 reply_id: 107984[/import]