[RESOLVED] How to create a basic loading screen

Hi,
I’m an ex Flash Developer who just started with Corona - awesome SDK!
I built a very simple running and jumping game for a client, but it is all contained in one big main.lua file.
It takes the game about 5 seconds to load, and it sits on a black screen.

Is there a super simple way I can create a loading image to replace the blank screen? The client just wants their logo to sit there, no need for a progress bar or anything.

Any help or pointers would be amazing, thanks in advance!
Garry [import]uid: 146743 topic_id: 33439 reply_id: 333439[/import]

I dont know how your game is set up
but this might work
in you main lua first thing you do is to load a full screen image “Loading…”

then the rest of you code comes
add all you GUI to a group with alpha = 0

last thing in you code you set
the alpha = 1 and destroy the “loading image”
you can also use groups
one group for loading image and one group for the rest

create group “main”
create group Loading
add full screen image to loading
run code , add GUI to “main”
remove/destroy group loading

[import]uid: 147488 topic_id: 33439 reply_id: 132837[/import]

Garry,

If you have it all in one main file… the easiest thing to do is…

  • just create a new image using “display.newImageRect” at the very start of your code

  • once your game loads - at the end of the loading … either remove the image or use the alpha property of the image to hide the image

Hope that helps

Vik [import]uid: 67619 topic_id: 33439 reply_id: 132858[/import]

Thanks guys,
I added:

local loadScreen = display.newImageRect(“images/gui/intro.jpg”, 480, 320 )

right at the start of my code, but it still starts with a blank screen - funnily enough it plays music that I added to the start, but it still won’t show the preloading image.

Any ideas?
Thanks again,
Garry
[import]uid: 146743 topic_id: 33439 reply_id: 132865[/import]

I think my error is that I’m not detecting the end of the load completion - is there an overall load completion event I can use (without tallying up all the individual load completion events of each asset?) [import]uid: 146743 topic_id: 33439 reply_id: 132866[/import]

easiest way to check

strip all the other code off leave your line

local loadScreen = display.newImageRect(“images/gui/intro.jpg”, 480, 320 )

does it bring up the image?

I don’t think there is load complete event… but if you add it to your last line of code in the loading it should work,
[import]uid: 67619 topic_id: 33439 reply_id: 132870[/import]

yep, stripping away the other code will just display my image [import]uid: 146743 topic_id: 33439 reply_id: 132871[/import]

dont forget to hide other gui in a group

and you can add a Default.png in the root folder
that image will be displayed before the lua script starts [import]uid: 147488 topic_id: 33439 reply_id: 132880[/import]

Omg, setting the Default.png file did the trick - that should be written in big letters on a guide somewhere :slight_smile:
Thanks so much!
You all rock!
Garry [import]uid: 146743 topic_id: 33439 reply_id: 132885[/import]

I know what you mean. There are some seriously good forum posts.

The best thing you can do is add “[RESOLVED]” to the start of you thread title.

I also think that there should be an FAQ linking to some of the best posts. [import]uid: 8271 topic_id: 33439 reply_id: 132895[/import]

Yeah I didn’t know about Default.png either and started creating my own loading code until I discovered it by accident.

Also it’s worth reading up on it in the Apple docs as there is other images you can include for landscape, portrait etc…

Dave [import]uid: 117617 topic_id: 33439 reply_id: 132902[/import]

I dont know how your game is set up
but this might work
in you main lua first thing you do is to load a full screen image “Loading…”

then the rest of you code comes
add all you GUI to a group with alpha = 0

last thing in you code you set
the alpha = 1 and destroy the “loading image”
you can also use groups
one group for loading image and one group for the rest

create group “main”
create group Loading
add full screen image to loading
run code , add GUI to “main”
remove/destroy group loading

[import]uid: 147488 topic_id: 33439 reply_id: 132837[/import]

Garry,

If you have it all in one main file… the easiest thing to do is…

  • just create a new image using “display.newImageRect” at the very start of your code

  • once your game loads - at the end of the loading … either remove the image or use the alpha property of the image to hide the image

Hope that helps

Vik [import]uid: 67619 topic_id: 33439 reply_id: 132858[/import]

Thanks guys,
I added:

local loadScreen = display.newImageRect(“images/gui/intro.jpg”, 480, 320 )

right at the start of my code, but it still starts with a blank screen - funnily enough it plays music that I added to the start, but it still won’t show the preloading image.

Any ideas?
Thanks again,
Garry
[import]uid: 146743 topic_id: 33439 reply_id: 132865[/import]

I think my error is that I’m not detecting the end of the load completion - is there an overall load completion event I can use (without tallying up all the individual load completion events of each asset?) [import]uid: 146743 topic_id: 33439 reply_id: 132866[/import]

easiest way to check

strip all the other code off leave your line

local loadScreen = display.newImageRect(“images/gui/intro.jpg”, 480, 320 )

does it bring up the image?

I don’t think there is load complete event… but if you add it to your last line of code in the loading it should work,
[import]uid: 67619 topic_id: 33439 reply_id: 132870[/import]

yep, stripping away the other code will just display my image [import]uid: 146743 topic_id: 33439 reply_id: 132871[/import]

dont forget to hide other gui in a group

and you can add a Default.png in the root folder
that image will be displayed before the lua script starts [import]uid: 147488 topic_id: 33439 reply_id: 132880[/import]

Omg, setting the Default.png file did the trick - that should be written in big letters on a guide somewhere :slight_smile:
Thanks so much!
You all rock!
Garry [import]uid: 146743 topic_id: 33439 reply_id: 132885[/import]

I know what you mean. There are some seriously good forum posts.

The best thing you can do is add “[RESOLVED]” to the start of you thread title.

I also think that there should be an FAQ linking to some of the best posts. [import]uid: 8271 topic_id: 33439 reply_id: 132895[/import]