Hi, There is any way to run a process (that takes a while) during the loader?
Shove a lot of great pictures into Assets. I usually do this to test the preloader.
Hi! Thanks for the answer, but I need to run a process (needed for the game) that takes a while before the game start. I don’t want to make the loader slower.
Your description of the task is too ambiguous, concretize.
If you need to pause at the end of which any function will be launched, you can use the Timer class
I have to run a process that takes too long at the start of the game, the behavior of this process is irrelevant, but I want that the loading bar continues until the process ends, because executing it after the loader has finished makes it look like it’s stuck.
Again it’s blurry. If it’s a built-in preloader that gets stuck right after the application is initialized after loading it in some process, then you should create a separate loader, To make it unlikely that the application is hanging, check that the execution time of the process does not exceed the budget of the frame
or dig in the direction of the custom loader.
Thank you! The custom loader will solve my problem.
Well after make the custom loader I figured out that this doesn’t solve the problem, I am running my process when the preloaders ends all the work (overriding onLoaded), but I want to update the progress (growing the loading bar) but this does not make any changes. I think that the render is never called until the onLoaded is over. There is any way to force the render?
You need to give the application time to process otherwise it’ll just sit there frozen, try building a custom update loop using Sys.sleep.
What platform are you targeting? Can you use a
Future, or other tool to run in a background thread?
Otherwise, yes, if it’s resource intensive, you will need to sleep somewhere in order to give the renderer a chance to redraw. It should redraw consistently, but it will be up to your code how often, and with what value, you show in your progress bar
Thank to both of you! I solved the problem with a Sleep in the some parts of the process. I tried with BarckgroundWorker but I’m targeting to HTML so it was executed inline.