We help IT Professionals succeed at work.

corona load images

jagguy
jagguy used Ask the Experts™
on
I am using corona sdk to make a game.
I need to know how can I tell when a series of images are loaded at startup?
IN actionscript3 there is a load event but in corona?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I've not used Corona, however I quick search of the site found the onSystemEvent method.  If event.type is "applicationStart" then it's equivalent to onLoad.

http://developer.anscamobile.com/content/application-programming-guide-common-design-tasks

The lifecycle of a program is different on a mobile platform.  The program can start then be suspend and resumed many times.  The "applicationExit" might only get called if the user turns the device off.  To work nicely on a phone an app can free its resources when it is suspended and reload when it is resumed.

If it needs more RAM, a mobile OS might ask the app to release as much memory as possible while it is suspended.

Corona looks like a nice system to program.  A bit like AS2 I guess.
Bear in mind, on a mobile device, memory is limited compared with the typical computer a web browser runs on.  It can run out and apps must share.

Author

Commented:
I am not seeing your logic here from that applicationStart event.

If I load say 100 images then how do I know when all these images are loaded?
I thought you were talking about the equivalent of page load, or app load.

Mobile devices don't load resources in parallel in the same way that web based system do.  If you tell it to load an image, then it will either be loaded or fail for some reason.

If you want the app to do something while loading, perhaps look into threading or timers.  Most phone apps just display a loading screen.  Parallel operations only tend to happen when dealing with the internet, loading from cloud storage is typically a parallel operation.

Corona has a function display.loadRemoteImage, you can add an event listener for that.
http://developer.anscamobile.com/reference/index/displayloadremoteimage
Commented:
I am making a game on mobile device.
In a game I test for collisions etc.

before I test for collisions on images I need to be sure that those images are loaded first or else the program can crash.

So what do I do in corona sdk to make sure all images are loaded fist before I start a gameloop?

Author

Commented:
i dont need the question