Loading Screen in corona sdk

Hey guys I have a question. Is there a way to create a loading screen that will load all the sprite sheets and images for my game. The reason why I ask this because in my game I have a lot of spirits and when I try to change scene my game would freeze for a sec and then change scene. I know I probably could use storyboard.loadScene ()
But I would like to create a load scene like in angry birds and cut rope

Could someone help me please

Thanks

Sean:
From Boxing Studio Games

Sure, you can use the techniques listed here:   http://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/

If the sprites are the same from scene to scene, you really only need to load them once.

Rob

So Rob I could use storyboard.loadScene ( ) in my loading screen in order to load my spirits for the menu scene, then in the menu scene I could call storyboard.loadScene () to load my next scene with a different sprite from the one I have in the menu scene?

Also thanks for pointing me to that tutorial I think I have a better understanding of goals now.

Thanks

Sean:

From Boxing Studio Games

Right and then when you call storyboard.gotoScene() after the scene is loaded, it will just call the enterScene() function since the createScene() is already done.

Rob

Thanks Rob I really appreciate your help

Sean:

From Boxing Studio Games

Sure, you can use the techniques listed here:   http://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/

If the sprites are the same from scene to scene, you really only need to load them once.

Rob

So Rob I could use storyboard.loadScene ( ) in my loading screen in order to load my spirits for the menu scene, then in the menu scene I could call storyboard.loadScene () to load my next scene with a different sprite from the one I have in the menu scene?

Also thanks for pointing me to that tutorial I think I have a better understanding of goals now.

Thanks

Sean:

From Boxing Studio Games

Right and then when you call storyboard.gotoScene() after the scene is loaded, it will just call the enterScene() function since the createScene() is already done.

Rob

Thanks Rob I really appreciate your help

Sean:

From Boxing Studio Games

Is there a tutorial showing how I could use a progess bar or similar else to load a scene like in many games I saw?

Hey, you could do what I did in my game. You could just simply call storyboard.loadScene ( ) to load other scene  create scene of the other file you want to load. You could do this by creating a normal storyboard or composer scene with an animation on screen displaying to the user that game is loading. The you could create a function that change the scene one the you think the images or texture object are loaded in memory to change the scene. I.E

storyboard.loadScene ( “menu”, true ) – loading the scene  

function change (event)  then

storyboard.gotoScene(“menu”,”fade”,300)

end

timer01 = timer.performwithdelay (3000, change, 1)  --[[After 3 seconds change the scene to menu.lua  ]]

Any Question ask

Sean

from BoxingStudioGames

Is there a tutorial showing how I could use a progess bar or similar else to load a scene like in many games I saw?

Hey, you could do what I did in my game. You could just simply call storyboard.loadScene ( ) to load other scene  create scene of the other file you want to load. You could do this by creating a normal storyboard or composer scene with an animation on screen displaying to the user that game is loading. The you could create a function that change the scene one the you think the images or texture object are loaded in memory to change the scene. I.E

storyboard.loadScene ( “menu”, true ) – loading the scene  

function change (event)  then

storyboard.gotoScene(“menu”,”fade”,300)

end

timer01 = timer.performwithdelay (3000, change, 1)  --[[After 3 seconds change the scene to menu.lua  ]]

Any Question ask

Sean

from BoxingStudioGames

Hi guys,
 

I have a question concerning the last technique here:

storyboard.loadScene ( “menu”, true ) -- loading the scene   function change (event)  then storyboard.gotoScene(“menu”,”fade”,300) end timer01 = timer.performwithdelay (3000, change, 1)  --[[After 3 seconds change the scene to menu.lua  ]]

I also try to load the scene for 3 second before using the gotoscene. I was wondering if anybody know what happen if i do a gotoscene before loadscene has finish loading. Would gotoscene try to reload the whole scene again OR take on from where the loadscene left?

Hey Bro, 

I think the answer to your question is very simple. I think the load function would pick up from where it left off.  Hence, once some of the texture objects are loaded into memory  corona   would need  reason to  reload the loaded scene. Unless, you try to remove the scene with a Lua or Corona garbage collector. If not the case, Corona would  continue to load texture into memory when the scene change. After you called the change function does the transition of the screens slow/pause for a sec ? If that is the case then you should delay the calling by about 6000 or 7000 seconds so you could load the textures into memory.

Second solution:

Another cool solution would be to check the memory that is being loaded and when you load the right amount of memory you could use a variable as a flag to change the scene. IE  

collectgarbage("collect") local memUsage\_str = string.format( "MEMORY= %.3f KB", collectgarbage( "count" ) ) print( memUsage\_str .. " | TEXTURE= "..(system.getInfo("textureMemoryUsed")/1048576) ) 

So you would need some way to calculate how much memory you need to load in order to change the VAR 

Heads Up I never used this second solution before so when I get back to my  work computer I will let the community know if it works.  

Any Questions ask

Sean 

From : Boxing Studio Games 

Thanks for your answer Sean,

Yes it does pause the transition or spritesheet animation for a couple seconds. I just wanted to be sure that if a scene takes 5 seconds to load(loadScene)  and then I call gotoScene 4 second after calling loadScene, that it doesnt take 9 seconds instead of 5. I guess I’ll have to run some more test to confirm this, I 'd been curious to hear from a Corona architect to confirm your saying.

thanks :slight_smile:

Any time bro 

Sean 

From : 

Boxing Studio Games 

Hi guys,
 

I have a question concerning the last technique here:

storyboard.loadScene ( “menu”, true ) -- loading the scene   function change (event)  then storyboard.gotoScene(“menu”,”fade”,300) end timer01 = timer.performwithdelay (3000, change, 1)  --[[After 3 seconds change the scene to menu.lua  ]]

I also try to load the scene for 3 second before using the gotoscene. I was wondering if anybody know what happen if i do a gotoscene before loadscene has finish loading. Would gotoscene try to reload the whole scene again OR take on from where the loadscene left?

Hey Bro, 

I think the answer to your question is very simple. I think the load function would pick up from where it left off.  Hence, once some of the texture objects are loaded into memory  corona   would need  reason to  reload the loaded scene. Unless, you try to remove the scene with a Lua or Corona garbage collector. If not the case, Corona would  continue to load texture into memory when the scene change. After you called the change function does the transition of the screens slow/pause for a sec ? If that is the case then you should delay the calling by about 6000 or 7000 seconds so you could load the textures into memory.

Second solution:

Another cool solution would be to check the memory that is being loaded and when you load the right amount of memory you could use a variable as a flag to change the scene. IE  

collectgarbage("collect") local memUsage\_str = string.format( "MEMORY= %.3f KB", collectgarbage( "count" ) ) print( memUsage\_str .. " | TEXTURE= "..(system.getInfo("textureMemoryUsed")/1048576) ) 

So you would need some way to calculate how much memory you need to load in order to change the VAR 

Heads Up I never used this second solution before so when I get back to my  work computer I will let the community know if it works.  

Any Questions ask

Sean 

From : Boxing Studio Games 

Thanks for your answer Sean,

Yes it does pause the transition or spritesheet animation for a couple seconds. I just wanted to be sure that if a scene takes 5 seconds to load(loadScene)  and then I call gotoScene 4 second after calling loadScene, that it doesnt take 9 seconds instead of 5. I guess I’ll have to run some more test to confirm this, I 'd been curious to hear from a Corona architect to confirm your saying.

thanks :slight_smile: