Game Development Community

Splash Screen

by baylor wetzel · in Torque Game Builder · 07/05/2006 (6:42 pm) · 1 replies

In main.cs it calls startGame but the comments say you should call a menu and a menu button should start the game. So that's what i tried to do. But i'm not doing it right

in main.cs, i comment out startGame and replaced it with Canvas.setContent(MainMenu); (not sure if that's the way you're supposed to load the main screen)

On MainMenu i created a button which has the command MainMenuHandler::onPlayButtonClicked(). onPlayButton has two lines. The first is echo("onPlayButtonClicked called"); which always fires, so i know i'm getting this far. The second is that startGame line from main.cs

When i click on TGB, the editor loads. When i hit F5/press start i see the level i was editing. MainMenu never comes and i never called startGame

Any ideas as to what i'm doing wrong?

#1
07/05/2006 (10:12 pm)
Let me see if I can explain. The level editor has a startGame wrapper of its own. So when you execute with F5 or clicking Run from the level editor, it basically calls startgame on the level file your working on. So your bypassing your setContent from initializeProject(). In the main.cs file under games/

look for this near the top.

$runWithEditors = true;

and change that to

$runWithEditors = false;

now you'll notice in your games/MyGame/main.cs file a section under initializeProject()

// Remove the following four lines if you would like to start the game without running the
   // level builder.
   if ($runWithEditors)
   {
      toggleLevelEditor();
      return;
   }

see whats its doing is saying, if you have $runWithEditors turned on, it will toggle the level editor on , and then return out of initializeProject so your Canvas.setContent() wont get called. By changing to false, Now execution can continue beyond that , and once your game starts , you can press F9 to toggleLevelEditor() via the keyboard, but you should see your startup sequence at least fire now.

Of course setting the $runWithEditors back to true reverses this behavior, and your game will startup into the levelEditor like your used too.

Hope that made sense :-)

-Rod