Progress Bar updating problem
by Chris Labombard · in Torque Game Builder · 02/18/2011 (8:18 am) · 1 replies
I programmed a progress bar using a t2dStaticSprite that will lengthen whenever I load a datablock.
I have a preloadDatablocks function I'm calling that calls incrementProgressBar function after every datablock loads.
The incrementProgressBar function calls setSize on my progress bar sprite but the change doesn't show up until after all of my datablocks have loaded.
I thought maybe it has to exit the script function before it updates so I scheduled each datablock creation for 0 ms.
I've echoed out the size of the static sprite and getRealTime to make sure it is advancing in time and actually changing the size and everything looks good but it still doesn't show the changes until everything is done.
Is there a way to force the image to update and show it's new size?
I have a preloadDatablocks function I'm calling that calls incrementProgressBar function after every datablock loads.
The incrementProgressBar function calls setSize on my progress bar sprite but the change doesn't show up until after all of my datablocks have loaded.
I thought maybe it has to exit the script function before it updates so I scheduled each datablock creation for 0 ms.
I've echoed out the size of the static sprite and getRealTime to make sure it is advancing in time and actually changing the size and everything looks good but it still doesn't show the changes until everything is done.
Is there a way to force the image to update and show it's new size?
About the author
I have been a professional game programmer for over 5 years now. I've worked on virtually every platform, dozens of games and released a few of my own games, including 2 iPhone titles and a title waiting release on Big Fish Games.
Torque Owner Chris Labombard
Premium Preferred
I set my schedules 50 ms apart (about a tick). There are about 150 datablocks being loaded from this.
schedule(50 * %c, 0, "performDBLoad", %c);
Now my progress bar looks great and TGB isn't froze for 10 seconds while it's loading. it gets graphical updates, as it should. It probably takes a few seconds more to load but it seems like less time because the user knows how far along it is.
I will test this on slower hardware and if I find that the time is too short I will post here.
I would release the code but my image loading logic is so customized it would be useless to anyone but me.