Changing levels
by baylor wetzel · in Torque Game Builder · 07/03/2006 (12:22 pm) · 2 replies
Hopefully this is the right forum to ask this
i've finished the tutorials. To learn more, i'm trying to make some simple modifications
What i'd like to do is switch to another level. If the user beats all the ships on level one, go to level two. Not sure how to do this
i'm sure this is easy to do but from the tool and the tutorials it wasn't clear to me how this works. When i start TGB, what i'm looking at is a level, right? And i can have multiple levels in one game, correct? The game.cs file is applicable to the whole game and not a level, ja? And global variables ($player) are global across levels?
i've finished the tutorials. To learn more, i'm trying to make some simple modifications
What i'd like to do is switch to another level. If the user beats all the ships on level one, go to level two. Not sure how to do this
i'm sure this is easy to do but from the tool and the tutorials it wasn't clear to me how this works. When i start TGB, what i'm looking at is a level, right? And i can have multiple levels in one game, correct? The game.cs file is applicable to the whole game and not a level, ja? And global variables ($player) are global across levels?
About the author
#2
both endGame() and startGame() crash TGB.exe when I try them. Any ideas what might be causing this?
This is Torque Game Builder v1.1.1 / Torque 2D v1.1.1.
Thanks.
09/15/2006 (12:43 pm)
I've tried using startGame() to load a new level, but it crashes TGB every time. I tried making a direct call to sceneWindow2D.loadLevel() and it too crashed TGB. This is the code I'm using:function EPlayer::onCollision(%srcObj, %dstObj, %srcRef,%dstRef, %time, %normal, %contactCount, %contacts)
{
if ($ThePlayer.gamePaused)
{
return;
}
if (%dstObj.isTrigger && %dstObj.triggerType $= "levelSuccess")
{
$ThePlayer.gamePaused = true;
echo("LOADING NEW LEVEL");
// endGame();
startGame("~/data/levels/poc_dungeon02.t2d");
}
}both endGame() and startGame() crash TGB.exe when I try them. Any ideas what might be causing this?
This is Torque Game Builder v1.1.1 / Torque 2D v1.1.1.
Thanks.
Torque Owner Tom Bushby
Where sceneWindow2D is your sceneWindow, and %level is the path to your level.
Thats in gameScripts/game.cs.
You can also use startGame(%level) where %level is the same as it would be above. This way you can do all level specific stuff, like reset variables, in startGame().
[I'm talking about TGB Pro, but it should apply to the demo.... Just checked, it does.]
Hope that helps,
- Tom.