How can I avoid getting a black screen for a second when reloading a scene?
Jump to content
A few options:
Load a background loading image into an intermediate scene.
Split up the drawing (and any other CPU-intensive code) of the scene into chunks. Load an image, wait a frame, load some more objects, wait a frame etc. You can use timers or an enterFrame listener for that.
It's hard to know what's going on here without seeing what you're doing. Common pitfalls that hit new users.
1. Setting a transition when going to the first scene. Typically you don't create any on-screen visuals in main.lua and use main.lua to go to your first scene. If you put a transition in that composer.gotoScene() call, then it's going to transition from the black default screen to your scene for the duration you set. If you want something on the screen immediately, don't use a transition on the first gotoScene() call.
2. You are not creating your scene in scene:create() but instead doing it in scene:show()'s "did" phase. If you're doing this then your code won't even attempt to create your scene until it's on the screen. This can cause these symptoms.
3. Doing too much in main.lua, before you attempt to show your scene, can lead to longer times before your scene shows. If you're loading a lot of audio in main.lua for instance, that will slow down your initialization.
Community Forum Software by IP.Board