Game Development Community

A simple loading bar for TGB [Resolved]

by Siobhan · in Torque Game Builder · 03/08/2011 (5:24 am) · 9 replies

Just wondering is it possible to create a really simple loading animation in TGB? I've looked up a few things but couldn't find anything useful.
I tried making an animated sprite but I guess I need a scenegraph to be able to run it?

I just want to make a little loading thing so that when the player starts the game and everything gets loaded that they know it's not just frozen on them and that it's actually just loading stuff. I have some music files which are really slowing down my loading time. They're .ogg. There's hardly a better format for music files that might load quicker?

#1
03/08/2011 (6:44 am)
If the Vorbis decoder had streaming support, we'd all be really happy. Until then, not much we can do. Even WAV files don't stream :/

In the basic GUI file (in my case, the only one in game/gui) I add a new t2dSceneWindow(transitionWindow), which I then use to load a special loading animation level into. Since it's a proper level, you can go nuts with effects and animations, but it's best to keep it lightweight (and preload everything on game launch).

Then you just call transitionWindow.endLevel() from the newly loaded level in the real game window. Or make a remove animation if you want the transition to be less sudden.
#2
03/08/2011 (8:58 am)
Awesome!
Just got your suggestion working. :D
Thanks so much. :)

But the wee animation I have won't play. Probably just something I've left out somewhere. Gonna look into it now. :)

Thanks again!
#3
03/08/2011 (9:31 am)
Try scheduling the loading:
gameWindow.schedule(100, "loadLevel", %level);
(Or whatever yours is called - I streamlined all my window names since I have so many by now.)

There's a global variable being set to point to the most recent scenegraph every time a level loads, which I've noticed causes strange things to happen to animations and particles.
#4
03/08/2011 (11:07 am)
That doesn't seem to make a difference...

What I have is this...

My animation sprite is called "loading".
And the animation I want to play is "loadingAnimation".

In game.cs:
function startGame(%level)
{
    transitionWindow.loadLevel("game/data/levels/loadingLevel.t2d");

    Canvas.setContent(mainscreengui);
    Canvas.repaint();
	
    loading.playAnimation("loadingAnimation");
	
    exec("./exec.cs");
    exec("./onStartUp.cs");

    Canvas.setCursor(DefaultCursor);
   
    new ActionMap(moveMap);
    moveMap.push();
   
    $enableDirectInput = true;
    activateDirectInput();
    sceneWindow2D.loadLevel(%level);
    onStartUp();
}

And I have my animationDatablock
(no idea if it's all correct)
new t2dAnimationDatablock(loadingAnimation) {  
    canSaveDynamicFields = "1";  
    imageMap = "loadingImageMap";  
    animationFrames = "0 1 2 3"; 
    animationTime = "1";  
    animationCycle = "1";  
    randomStart = "0";  
    startFrame = "0";  
};
#5
03/08/2011 (11:46 am)
Ah, I haven't tried that approach. What I do is quite simple: I drag an animation in the editor into the loading screen level. When it loads, it plays. Simple as that :)

Also make sure the transition window is defined last, because they are created back to front in the order listed in the GUI file.
#6
03/08/2011 (1:43 pm)
Ah okay. I was just looking up how to do animated sprites and that was the kinda thing I was being told to do!
I had just dragged my animation into the level builder but it wasn't animating for me.
It's pretty much like the whole thing just freezes while it's loading up the music. Can't even move the cursor around.
Maybe that's why it won't play. Everything gets frozen while the music loads.
#7
03/10/2011 (6:45 am)
I'm pretty sure I had a 15 minutes long streamed track playing trough the game, so preloading audio may actually be unnecessary.

At least put up a static image saying "Loading. Please wait." or something. It will give enough information to the player. It's nice to have an animated load screen, but not really necessary.
#8
03/10/2011 (7:22 am)
Yep!
Just discovered yesterday from browsing through some forum posts that you can actually stream music by putting "isStreaming = true;" into the audioDescription. :)

Huzzah! I don't need a loading screen anymore but at least I know how to make one if ever the need should arise. :)
#9
03/10/2011 (8:17 am)
Yeah, it still doesn't stream graphics ;)