I am trying to create a loading screen that preloads a large amount of text data from various text files into a dictionary. I am using scenes, having main load a static background then transfer to the loading scene. The loading scene is supposed to store the data using a loop, periodically updating a series of images indicating the loading progress. However, the images are not displaying until the data loop has completely finished, even though console printouts still update correctly. I had this problem when attempting to do this all in main, hence the attempt to do it with scenes.
The basic outline of the code is:
for x = 1, eachDataItem do
storeCurrentData(x)
if certainCriteria == true then
updateDisplay()
print(certainCriteria)
end
end
The data stores correctly, the console printouts print, but the display doesn’t update until the loop has finished.
Edit: I have come up with 3 possible solutions to sidestep the problem, though I am still curious what is wrong with the original.
-
Just use a static loading screen with a warning it may take a while.
-
Use an individual scene for each step. The display should update before transitioning to the new scene.
-
Not sure on this one, but maybe load an animated background with main and see if it still updates correctly during the file loading.
Final edit: I went the multiple scene route since I could not get a timely answer, turning the single loading scene into 8 scenes: a preloader, 6 scenes that each do one run of the original loop, and a postloader to clean everything up before transitioning to the menu. It’s silly and counterintuitive, but it works.