luacoronasdkcorona-storyboard

How to implement a loading screen using storyboard?


In a Corona app using the storyboard library, what are the best practices for adding a loading screen between scenes? I'm guessing it should go somewhere in scene:enterScene() but I'm not sure how to make it work with Corona's rendering process. As I understand it, if I do the following, the loading screen would never be displayed since Corona waits until the code path has finished and then draws everything at once.

function scene:enterScene( event )
  showLoadingScreenOverlay()
  loadEverything()
  hideLoadingScreenOverlay()
end

Is the correct approach to create a new storyboard scene for the loading screen itself? If so, how can I load the other content in the background while the loading scene is displayed?


Solution

  • In your case, you should be using loadScene(): http://docs.coronalabs.com/api/library/storyboard/loadScene.html

    This will only call the createScene part of your new scene2... Then what you could do is update loading progress in the createScene of scene2, and verify every x milliseconds in your original scene1 the loading progress. When it is 100%, just call goToScene in scene1 and it will load scene2 instantly.