Game Development Community

Levels overwriting each others

by Gustavo Boni · in Torque Game Builder · 02/07/2007 (6:33 am) · 6 replies

Hi guys,

Using the Advanture kit like a template, i added one level to my game. The problem is when i load another level on the fly, the level to be loaded is overwrited by the previous level. I'm using this to make sure i unload the current level:

if ( isObject( $levelScene ) )
      sceneWindow2D.endLevel();

I dont have any idea why its happening. Any help would be appreciated.

#1
02/07/2007 (7:26 am)
Can you tell us in which file and function that code is located (e.g. main.cs, gamescripts/game.cs)?

In the main.cs file there is usually something like this:

function initializeProject()
{
    ... other stuff ...

    startGame( $levelEditor::LastLevel[ $currentProject ] );
}

and in game.cs:

function startGame( %level )
{
    ... other stuff...

    if( isFile( %level ) || isFile( %level @ ".dso"))
        sceneWindow2D.loadLevel(%level);
}

Perhaps the $levelEditor::LastLevel is the place to look?

If you could post a bit more code it would help us track the issue down faster.
#2
02/07/2007 (7:39 am)
@Neon: i'm using the Adventure Kit so the code is a bit different. Basically i have a fucntions wich load the level and call sceneWindow2D.loadLevel(%level). I think i'm not allowed to post Adventure kit code here.

The strange thing is sometimes the engine create a copy of my level in another file level, like a copy/paste.
#3
02/07/2007 (7:42 am)
I don't have access to the Adventure Kit so perhaps repost on that private forum?

Tom/Russel would be sure to have some ideas.
#4
02/07/2007 (8:02 am)
Thanks for the help Neo, i appreciate that. =)
#5
02/08/2007 (12:18 pm)
If you call loadLevel, it's supposed to unload the currently loaded level for you. Only persistent objects should remain in the scene. If you wanted to keep the old level around and just add objects from a seperate level to the scene you can call addToLevel.

Is any of this not working as I described it? Am I correct to understand that you're seeing objects from the previously loaded level remaining in the scene when loading a new level? Is TGB actually modifying your level files?

Any more information would be very helpful. If this is a bug, we would like to resolve it to avoid future confusion, especially if we are potentially damaging anyone's level files.
#6
02/08/2007 (12:51 pm)
Hi Thomas, thanks to reply.

Yes, TGB is replacing my level files. I notice minutes ago that if i load the level "X" in the level editor and in my code i load the level "Y" and play the game, TGB will replace my level "X" with level "Y" code.
I think its not a AK bug, i modified some things in the code to fit in my game features. Basically i added a new loadingscreen to load a new level.