main menu toggle problem
by gaetano · in Torque Game Builder · 02/04/2011 (12:57 am) · 3 replies
I'm italian, so, sorry my really bad english.
I fallow the mini tutorial for create a main menu openable pressing "delete".
The menu run correctly! but how can i do if i want to run the menu at the game start, without push the "delete" button?
I tryed to do all the modify you can imagine in this code, but all i do is useless!
here is my first part of "menuCommand.cs" (sorry but i don't know how to use spoiler)
-----------------------------------------------------------------------
moveMap.bindCmd(keyboard, "delete", mainMenuGui @ ".toggleMenu();", "");
// mainMenu onLevelLoaded callback
function mainMenuGui::onStart(%this, %scenegraph)
{
%this.menuOpen = %false;
}
// show the main menu
function mainMenuGui::toggleMenu(%this)
{
if(!%this.menuOpen)
{
Canvas.pushDialog(%this);
%this.menuOpen = true;
}
else
{
Canvas.popDialog(%this);
%this.menuOpen = false;
}
}
-----------------------------------------------------------------
I hope someone can help me!
I fallow the mini tutorial for create a main menu openable pressing "delete".
The menu run correctly! but how can i do if i want to run the menu at the game start, without push the "delete" button?
I tryed to do all the modify you can imagine in this code, but all i do is useless!
here is my first part of "menuCommand.cs" (sorry but i don't know how to use spoiler)
-----------------------------------------------------------------------
moveMap.bindCmd(keyboard, "delete", mainMenuGui @ ".toggleMenu();", "");
// mainMenu onLevelLoaded callback
function mainMenuGui::onStart(%this, %scenegraph)
{
%this.menuOpen = %false;
}
// show the main menu
function mainMenuGui::toggleMenu(%this)
{
if(!%this.menuOpen)
{
Canvas.pushDialog(%this);
%this.menuOpen = true;
}
else
{
Canvas.popDialog(%this);
%this.menuOpen = false;
}
}
-----------------------------------------------------------------
I hope someone can help me!
#2
Canvas.pushDialog(mainMenuGui);
after the code that loads the level in the startGame function in game.cs
Also, make sure you have run
exec("~/gui/yourGuiFile.gui");
before you try to push it to the canvas. I have not tried the tutorial, but I hope that this will make your gui show during startup.
02/09/2011 (12:52 am)
Try putting Canvas.pushDialog(mainMenuGui);
after the code that loads the level in the startGame function in game.cs
Also, make sure you have run
exec("~/gui/yourGuiFile.gui");
before you try to push it to the canvas. I have not tried the tutorial, but I hope that this will make your gui show during startup.
#3
What I want to have is a Main Menu that is triggered "on load" of one level and that I can access from everywhere by pressing a key. The second option works just fine but the first one is the one I am not sure how to implement.
06/15/2011 (2:18 pm)
Hi, I followed the same tutorial but have added some splash screens that show up before the main screen. These splash screens are level files with just one graphic and a behavior script that let them fade in and out.What I want to have is a Main Menu that is triggered "on load" of one level and that I can access from everywhere by pressing a key. The second option works just fine but the first one is the one I am not sure how to implement.
gaetano