Load new Levels
by Danny Mejia · in Torque Game Builder · 12/21/2006 (7:54 pm) · 7 replies
What is the best way to load a new level. I have most of my game play done for 3 levels but I just to load the next level when the player.
About the author
#2
12/22/2006 (1:36 pm)
When player as won level 1 I need to to level and so on. Sorry about that.
#3
12/22/2006 (10:02 pm)
Well, for starters look up the endLevel() and loadLevel() methods of the t2dSceneWindow object in the docs
#4
If I read the docs there is not any example... so I try to set this condition to end the level doing this:
But with this my level is ended and nothing else happens, a new level is not loaded.
We have this function in game.cs to start the actual level... but how can we reference a specific labeled level? I mean, if my first level is labeled startgamelevel.t2d, what can I do to start the game loading that specific level and how can I do to stop the game functions when this level is finished and how can I restart that functions for the next level?
I believe that docs are not so detailed as begginers would need :( so extra help from the community is highly needed :)
Thanks!
01/03/2007 (8:30 am)
Not Clear At All:If I read the docs there is not any example... so I try to set this condition to end the level doing this:
if( %this.goldCount $= 64)
{
SceneWindow2D.endLevel();
SceneWindow2D.loadLevel(%Level2); //I have two levels, one is Level1.t2d, other Level2.t2d
}But with this my level is ended and nothing else happens, a new level is not loaded.
We have this function in game.cs to start the actual level... but how can we reference a specific labeled level? I mean, if my first level is labeled startgamelevel.t2d, what can I do to start the game loading that specific level and how can I do to stop the game functions when this level is finished and how can I restart that functions for the next level?
if( isFile( %level ) || isFile( %level @ ".dso"))
sceneWindow2D.loadLevel(%level);
moleGuiGameOver.visible = 0;I believe that docs are not so detailed as begginers would need :( so extra help from the community is highly needed :)
Thanks!
#5
so a level must be defined before call its load!
01/03/2007 (10:11 am)
Hmmmm :)so a level must be defined before call its load!
%level = "ProjectName/data/levels/Level1.t2d";
if( isFile( %level ) || isFile( %level @ ".dso"))
sceneWindow2D.loadLevel(%level);
moleGuiGameOver.visible = 0;
#6
A different approach would be a simple variable that holds the current level number and do this instead:
01/06/2007 (1:45 am)
You would need to assign it to $levelX where X is the level number. % won't help, that are local variables which can only be accessed from within the actual function they have been declared.A different approach would be a simple variable that holds the current level number and do this instead:
%level = "ProjectName/data/levels/Level" @ ($levelNumber + 1) @ ".t2d"; $levelNumber = $levelNumber + 1; SceneWindow2D.loadLevel(%level);
#7
Preferrable
More compact (note: I think compactness of high level code is 100% irrelevant to any programming decision that should ever be made. The way we read things and the way the compiler reads things are not related)
01/06/2007 (10:50 am)
I'm not saying this is the best way to do what you're trying to do as I haven't been following the thread. Two possibly cleaner and easier to understand/follow/maintain ways to write that last code tidbit:Preferrable
$levelNumber = $levelNumber + 1; %level = "ProjectName/data/levels/Level" @ ($levelNumber) @ ".t2d"; SceneWindow2D.loadLevel(%level);
More compact (note: I think compactness of high level code is 100% irrelevant to any programming decision that should ever be made. The way we read things and the way the compiler reads things are not related)
%level = "ProjectName/data/levels/Level" @ ($levelNumber++) @ ".t2d"; SceneWindow2D.loadLevel(%level);
Torque Owner Drew -Gaiiden- Sikora