How to unload and load a new scene
by Matthew Shrewsbury · in Torque Game Builder · 07/27/2011 (7:55 pm) · 9 replies
Hello everyone,
I have been raking my brain around on this for a little while now and I figure I would post my question in the forms.
Ok here is goes, I have my starting scene named Main.t2d with mainScreen.Gui attached to it. From my mainScreen.gui I have several buttons on it (start, end, options and ect) I want to have my start button delete the current scene / gui and load a new set. The new files are called Select.t2d and select.gui.
From mainScreen.gui I have my start button linked to this function.
// start of char select
function charSelect()
{
sceneWindow2D.endLevel();
mainScreenGui.dump();
}
And here is a snip from my console log
>>> Advanced script error report. Line 50.
>>> Some error context, with ## on sides of error halt:
function endGame()
{
sceneWindow2D.endLevel();
moveMap.pop();
moveMap.delete();
}
// start of char select
function charSelect()
{
sceneWindow2D.endLevel();
mainScreenGui.dump();
sceneWindow2D.loadLevel(@"datalevelsSelect.t2d");
## ##
}
>>> Error report complete.
So what is the best way to make the transition from one scene to the next?
I have been raking my brain around on this for a little while now and I figure I would post my question in the forms.
Ok here is goes, I have my starting scene named Main.t2d with mainScreen.Gui attached to it. From my mainScreen.gui I have several buttons on it (start, end, options and ect) I want to have my start button delete the current scene / gui and load a new set. The new files are called Select.t2d and select.gui.
From mainScreen.gui I have my start button linked to this function.
// start of char select
function charSelect()
{
sceneWindow2D.endLevel();
mainScreenGui.dump();
}
And here is a snip from my console log
>>> Advanced script error report. Line 50.
>>> Some error context, with ## on sides of error halt:
function endGame()
{
sceneWindow2D.endLevel();
moveMap.pop();
moveMap.delete();
}
// start of char select
function charSelect()
{
sceneWindow2D.endLevel();
mainScreenGui.dump();
sceneWindow2D.loadLevel(@"datalevelsSelect.t2d");
## ##
}
>>> Error report complete.
So what is the best way to make the transition from one scene to the next?
About the author
#2
One other question in regards to this topic. One other part to this, how do you remove a gui and load another in its place?
I want to remove "mainScreenGui.gui" and load "select.gui" in its place for the next scene.
07/28/2011 (3:17 pm)
Thank you very much that worked like a champ. I do apologize for placing this thread in the wrong spot. One other question in regards to this topic. One other part to this, how do you remove a gui and load another in its place?
I want to remove "mainScreenGui.gui" and load "select.gui" in its place for the next scene.
#3
07/28/2011 (4:14 pm)
You will want to use Canvas.pop() to remove a GUI, then Canvas.pushDialog() to put the other on the stack.
#4
07/28/2011 (5:15 pm)
Thank you very much, that worked like a charm. Thank you very very much for all your help.
#5
07/29/2011 (8:33 am)
How did you set your start level?
#6
You can have a global variable, like:
Or you can just specify using a string:
Totally up to you.
07/29/2011 (12:24 pm)
@Laura - You can use any variable you want to set a starting level, so long as you use this code:sceneWindow2D.loadLevel(%level);
You can have a global variable, like:
$StartingLevel = "game/data/firstLevel.t2d"; sceneWindow2D.loadLevel($StartingLevel);
Or you can just specify using a string:
sceneWindow2D.loadLevel("game/data/firstLevel.t2d");Totally up to you.
#7
07/29/2011 (12:28 pm)
Oh. Okay. Thanks!
#8
07/29/2011 (12:45 pm)
Now is a good time to pop into IRC and ask :)
#9
Also I noticed that Canvas.pop is not a recognizable command. What command should I use to remove a GUI ?
Can anyone point me in a direction of Canvas commands?
<---Log file--->
Loading compiled script C:/Users/Matthew/Desktop/KKF - Great CAKe Capper/game/data/levels/Main.t2d.
game/gameScripts/game.cs (51): Unknown command pop.
Object canvas(1112) canvas -> GuiCanvas -> GuiCanvas -> GuiControl -> SimGroup -> SimSet -> SimObject
Loading compiled script C:/Users/Matthew/Desktop/KKF - Great CAKe Capper/game/data/levels/Select.t2d.
08/20/2011 (8:04 am)
Where can I find the IRC chat channel information? Also I noticed that Canvas.pop is not a recognizable command. What command should I use to remove a GUI ?
Can anyone point me in a direction of Canvas commands?
<---Log file--->
Loading compiled script C:/Users/Matthew/Desktop/KKF - Great CAKe Capper/game/data/levels/Main.t2d.
game/gameScripts/game.cs (51): Unknown command pop.
Object canvas(1112) canvas -> GuiCanvas -> GuiCanvas -> GuiControl -> SimGroup -> SimSet -> SimObject
Loading compiled script C:/Users/Matthew/Desktop/KKF - Great CAKe Capper/game/data/levels/Select.t2d.
Community Manager Michael Perry
ZombieShortbus
@Matthew - The problem is this line of code:
Remove the @ symbol.