Game Development Community

Loading screen isn't updating every time

by Justin Mosiman · in Torque Game Builder · 07/28/2009 (4:06 am) · 1 replies

Hi,

I am trying to create a simple loading screen that basically says what it is loading at the beginning of the level. I have gotten this working except the text doesn't always change even though it is loading that portion of the code. Here is what I am doing:

function startGame()
{
   LoadingStatus.setText("Loading First...");
   scheduleFunction("loadDatablocks","First");   
}

function scheduleFunction(%function,%arg)
{
	schedule(500,0,%function,%arg);
}

function loadDatablocks(%level)
{
   switch$(%level){
      case "First":  
         $DataManager.loadFirstDatablocks();
			LoadingStatus.setText("Loading Second...");
   		scheduleFunction("loadDatablocks","First");
			break;
      case "Second":
         $DataManager.loadSecondDatablocks();
			LoadingStatus.setText("Loading Third...");
   		scheduleFunction("loadDatablocks","Third");
			break;
		case "Third":
         $DataManager.loadThirdDatablocks();
			LoadingStatus.setText("Done Loading...");
   		scheduleFunction("loadGame");
			break;
   }
}

I have to call scheduleFunction because otherwise the screen would never refresh with the new LoadingStatus text. Is there a better way to do this? From running this example, I always see loading first and second, but then it goes straight to done. I never see it say "Loading third", even though it does in fact load it.

Thanks,
Justin

#1
07/28/2009 (4:30 am)
After you apply the text, try adding the following line:

Canvas.repaint();

It will force the Canvas to redraw itself.