Game Development Community

Fading Help! Pulling my hair out....

by Kevin Epps · in Torque Game Builder · 03/03/2007 (1:23 pm) · 4 replies

I need help writing a fading to black transition for one level to another.

My first level is set up like this (in this order of layers)

MainMenu level view
Menu gui view

I have a black t2dStaticSprite that I've written a function for to fade in and out, but the problem is when it fades, the menu gui still shows due to how it's called in game.cs.

// Set The GUI.
   Canvas.setContent(mainScreenGui);
   Canvas.setCursor(DefaultCursor);
   //Set Main Screen buttons
   Canvas.pushDialog(mainGui);
   
   moveMap.push();
   
   if( isFile( %level ) || isFile( %level @ ".dso"))
      $currentLevel = sceneWindow2D.loadLevel(%level);

What I want to know is there a way to somehow push a t2dStaticSprite or any t2d object in front of everything else (images, gui, mouse, etc.)?

Or am I going about this fading all wrong? The only fading help that I see here is dealing with fading out objects, but not really fading the "screen" to a color. And the splash tutorial wouldn't really work for me, as it has that waitTime member.

Somebody help! There has to be a simple way to do something that games have been doing pretty much since the 80's.

#1
03/06/2007 (8:25 am)
***bump***
#2
03/06/2007 (9:15 am)
Hmmm... I'm no programmer but couldn't you possibly create a second scenegraph on top of the first and use the second scenegraph to cover the first with the black sprite you're using for the fades? Seems a bit overkill for a simple fade and I'm not sure it'll work.

This tutorial on TDN might help: GUI Particles

*EDIT: Slight clarification
#3
03/06/2007 (11:19 am)
Thanks!

I used that GUI Particles tutorial and just changed this code to suit my needs:

Canvas.pushDialog(screenFX, 1);
        new t2dSceneGraph(fxSceneGraph);
   sceneFXWindow.setSceneGraph(fxSceneGraph);
   sceneFXWindow.setCurrentCameraPosition ("0 0 100 75" );
   %effect = new t2dStaticSprite(whiteFade) { scenegraph = sceneFXWindow.getScenegraph(); };
   %effect.setImageMap("white_wallImageMap", "0");
   $effect.setBlendColour("1", "1", "1");
   %effect.setBlendAlpha("0.0");
   %effect.setPosition("0", "0");
   %effect.setSize("100", "75");

Of course the Image Map was declared using Level Builder. It works perfectly!! :)
#4
03/06/2007 (1:56 pm)
Sweet! Glad I could help!