TGB 1.7 Gui Tutorial
by Geoff "Cardboard" Gibson · in Torque Game Builder · 09/11/2009 (2:07 pm) · 3 replies
Hello,
I've recently been using TGB and just completed my first game tutorial, the Fish Game. Itw as fun and I enjoyed it a lot. However, in order to begin teaching myself outside of full tutorials I wanted to add a few things to the game that wasn't already included in the game. Mainly a score board and a main menu with which to begin the game. Unfortunately the only GUI tutorial I could find seems to be very outdated:
http://tdn.garagegames.com/wiki/TGB/MiniTutorials/GUIScoreAndTime
The GUI builder in my version looks nothing like that builder. Is there an updated tutorial around here somewhere? Is this just something I'm going to have to learn on my own? If the latter, are there any helpful tips you can give me?
Much appreciated!
I've recently been using TGB and just completed my first game tutorial, the Fish Game. Itw as fun and I enjoyed it a lot. However, in order to begin teaching myself outside of full tutorials I wanted to add a few things to the game that wasn't already included in the game. Mainly a score board and a main menu with which to begin the game. Unfortunately the only GUI tutorial I could find seems to be very outdated:
http://tdn.garagegames.com/wiki/TGB/MiniTutorials/GUIScoreAndTime
The GUI builder in my version looks nothing like that builder. Is there an updated tutorial around here somewhere? Is this just something I'm going to have to learn on my own? If the latter, are there any helpful tips you can give me?
Much appreciated!
#2
I'm still a bit foggy on the GUI builder thing, but with your code snippets it's definitely helped figure out the bulk part of it.
Anybody else with an actual tutorial is always welcome to contribute though. Every little bit helps. :)
09/11/2009 (5:19 pm)
This helped A LOT.I'm still a bit foggy on the GUI builder thing, but with your code snippets it's definitely helped figure out the bulk part of it.
Anybody else with an actual tutorial is always welcome to contribute though. Every little bit helps. :)
#3
09/11/2009 (8:56 pm)
Stashing this for the future too :) Thanks BW!
Torque 3D Owner baylor wetzel
There used to be a tutorial on a pirate-map looking main menu. Here's a snippet of how i'm doing it in my current game:
game.cs
function startGame(%level) { //--- Weird screen res for iPhone compatibility setScreenMode( 960, 640, 32 , false ); //--- Sound only seems to come from channel 0 //--- TGB *ALWAYS* defaults to 0.8, even when you change it in the IDE //--- And it's not 20% quieter, it's 1/2 volume (and 0.5 is basically off) alxSetChannelVolume(0, 1); // TODO: read this from a config file $runWithSplashScreens = false; $runWithMenus = true; if ($runWithSplashScreens) { // i'm not going to show you the code for this right now // since you want to just see a main menu $gameFlowManager = getGameFlowManager(); $gameFlowManager.begin(); } else if ($runWithMenus) { showMainMenu(); } else { startPlaying(); } } function startPlaying() { initializeGame(); // game specific stuff safeLoadLevel("mapLevel"); // a function i wrote }gameFlowManager.cs
function showMainMenu() { // this is the magic function you want Canvas.setContent(MainMenu); alxStopAll(); if ($musicIsEnabled) $backgroundMusic = alxPlay(mainMenuMusic); }MainMenu is a GUI with a 800x600 image in the background (or somesuch; they all resize to your game). It has a panel and on the panel are buttons (assigning a button a panel used to require a magic password no one knew, specifically right clicking on it until it highlights, signifying that it was the container; this is why documentation is so important, no one was going to guess that). The buttons all have a name (if you assign one) and an automatic onClick event
mainMenu.cs
function MainMenu::exit(%this) { quit(); } function MainMenu::loadGame(%this) { MessageBoxOK("You pressed load!", "Sorry, i haven't written Load yet"); } function MainMenu::newGame(%this) { //--- Stop playing the main menu background music alxStopAll(); startPlaying(); } function MainMenu::showAchievements(%this) { safeLoadLevel("achievementsLevel"); } function MainMenu::showCredits(%this) { Canvas.pushDialog("creditsGUI"); } function MainMenu::showHelp(%this) { Canvas.pushDialog("helpGUI"); }