Game Development Community

How to script an animated splash screen

by Alex Rice · in Torque Game Builder · 09/10/2005 (11:11 pm) · 3 replies

I am putting up an animated sprite that says "loading..." and proceeding to load all datablocks and scripts etc. There is an unpredicatable amount time after the calls to setup the scene and before stuff starts appearing on screen. At first there is just a black screen. I am using schedule() to separate the work out. I realize that the event loop has to be given time to render etc.

After this code in client.cs
new fxSceneGraph2D(t2dSceneGraph);
sceneWindow2D.setSceneGraph( t2dSceneGraph );
~ 1500 ms before stuff appears on screen (on my computer and I'm sure it must vary depending on cpu power)

Is there a callback that you can get for when stuff has actually actually appearing on screen?

My setupT2DScene ends with

exec("./loading.cs"); //puts up loading animated sprite
schedule(1500, 0, setupT2DSceneContd); // wait for it to appear doing more work

Of course this defeats the purpose of having a loading animation altogether :-)

#1
09/10/2005 (11:17 pm)
And I know about the EULA requirement for a Torque splash screen- I plan on doing that was well. But I was hoping to have an intelligent "loading..." kind of thing going on.
#2
09/11/2005 (3:05 am)
Most of the time, people just use the "GuiFadeinBitmapCtrl" and a bitmap. You can see this being used in the T2D demos.

With regards to the apparent "rendering delay", well there isn't one directly. What you'll find is that the engine-processing loop doesn't begin until the root "main.cs" has completed and you'll be making calls from within a "mod" that is being launch within it. There is no parallel processing here, everthing is sequential.

You can of course restructure the root "main.cs" so that it only executes minimal script and defers the reset of the initialisation of your datablocks etc a schedule.

Hope this helps,

- Melv.
#3
09/11/2005 (10:39 am)
Thanks Melv, I will probably just use the fade in bitmap, but if it's possible to do a "loading..." splash screen or even a progress meter, that would be better. Here is some code with annotations about what I think is going on. If anyone has tried this before maybe you can make some suggestions

// in T2D/client/client.cs
function setupT2DScene()
{
   new fxSceneGraph2D(t2dSceneGraph);
   sceneWindow2D.setSceneGraph( t2dSceneGraph );
   sceneWindow2D.setCurrentCameraPosition( "0 0 100 75" );
   // this puts an animated "loading..." sprite on-screen:
   exec("./loading.cs");
   // unless this is increased to 1500 ms wait time, the sprite does not appear:
   schedule(1, 0, setupT2DSceneContd);
   // if the wait time is < 1500 all that is seen is a black screen
   // because the loading sprite is removed by the following function:
}

function setupT2DSceneContd ()
{
   exec("./demoDatablocks.cs");
   exec("./datablocks.cs");
   exec("./debug.cs");
   exec("./keybind.cs");
   exec("./geometry.cs");
   exec("./basicInteractionModel.cs");
   exec("./maps/mapLoader.cs" );
   TTA::loadMap("memory1");
   // delete the "loading..." animated sprite
   TTA::stopLoadingAnim();
}

Again, thinking that the event-loop has not had time to render everything so I added another schedule() call in TTA::stopLoadingAnim():


function TTAstopLoadingAnimScheduled () 
{
   $gLoadingAnim.safeDelete(); 
} 

function TTA::stopLoadingAnim ()
{
   schedule( 1, 0, TTAstopLoadingAnimScheduled);
}

And I am seeing the same thing [edit: on this end] of the work. If the time is < 1500 then the sprite does not appear, just a black screen, but if the time is > 1500 then I see the sprite and a moment later is removed by stopLoadingAnim