Game Development Community

How to set the DefaultScene

by Clubber · in Torque Game Builder · 07/01/2010 (6:32 pm) · 2 replies

Ok take it easy I’m a noobie to programming well more like a zero.
What I’m trying to do, is have a splash screen come up then switch or start my level.
I’ve got the splash screen working but after that it just sits there with a black screen.
I want to set the scene myself as there will be several and I don't know how torque will
pick which is the first one.
I think I've got to put this variable in

$defaultScene = "~/data/levels/level1Pt1.t2d";

But I have no idea which file or where ? is it in my game.cs
and do I put it inside a function or outside a function
or do I call it up somewhere else


Here's a copy of my main.cs


function initializeProject()
{
// Load up the in game gui.
exec("~/gui/mainScreen.gui");
exec("~/gui/splashScreen.gui");
$defaultScene = "~/data/levels/level1Pt1.t2d";

// Exec game scripts.
exec("./gameScripts/game.cs");

// This is where the game starts. Right now, we are just starting the first level. You will
// want to expand this to load up a splash screen followed by a main menu depending on the
// specific needs of your game. Most likely, a menu button will start the actual game, which
// is where startGame should be called from.
//startGame( expandFilename($Game::DefaultScene) );
loadSplash();
}

function loadSplash()
{
canvas.setContent(Splash);
schedule(100,0,checkSplash);
}
function checkSplash()
{
if (Splash.done)
startGame(expandFilename($Game::DefaultScene));
else
loadSplash();
}

//---------------------------------------------------------------------------------------------
// shutdownProject
// Clean up your game objects here.
//---------------------------------------------------------------------------------------------
function shutdownProject()
{
endGame();
}

//---------------------------------------------------------------------------------------------
// setupKeybinds
// Bind keys to actions here..
//---------------------------------------------------------------------------------------------
function setupKeybinds()
{
new ActionMap(moveMap);
//moveMap.bind("keyboard", "a", "doAction", "Action Description");
}




It's tough going with GUI stuff there no decent tuts in simple steps
so any help will be appreciated
Thanks


#1
07/03/2010 (9:30 am)
Execute this code in your checkSplash function:
%level = expandFilename("~/data/levels/level1Pt1.t2d");
sceneWindow2D.loadLevel(%level);

The t2d file usually sits in your project directory inside game/data/levels.
#2
07/03/2010 (6:32 pm)
Thanks you're the man !!!