Load new Levels
by Harrison Brock · in Torque Game Builder · 12/25/2006 (11:33 pm) · 5 replies
#2
12/27/2006 (8:42 am)
Yea that's right. Where this goes exactly would depend on the way your game is laid out. But it's pretty straightforwards - You should call this before you try and manipulate any objects that are part of that level
#3
This seems to be what you are doing that it does not want you to do...
"Notes:
This method is defined in script.
Warning: Don't call loadLevel() from a function call that is on an instance of an object that is currently in the scenegraph that is going to be deleted and replaced by the new level."
12/29/2006 (10:08 pm)
I am just learning this myself but I did find this warning in the Docs under LoadLevel Method.This seems to be what you are doing that it does not want you to do...
"Notes:
This method is defined in script.
Warning: Don't call loadLevel() from a function call that is on an instance of an object that is currently in the scenegraph that is going to be deleted and replaced by the new level."
#4
however, one prob which i encountered occasionally is that TGB crushes when i called loadlevel when i call it in an object's function call. So what i did was to do a schedule:
sceneWindow2d.schedule(200, loadlevel, %filename);
01/19/2007 (1:58 am)
Hi, just an observation that endlevel() is already called in loadlevel(). however, one prob which i encountered occasionally is that TGB crushes when i called loadlevel when i call it in an object's function call. So what i did was to do a schedule:
sceneWindow2d.schedule(200, loadlevel, %filename);
#5
What's happening is that when you call loadlevel, and therefore unloadlevel from within a scope that depends on an object that gets unloaded, and follow-on references (script or engine internal c++) now has an undefined reference to an object (since you unloaded the object).
a schedule of zero duration simply sets the function to be scheduled to occur the very next time we are at a "safe" scoping level, thereby avoiding the possibility of deleting objects "out from underneath" the code they are using.
01/19/2007 (2:17 pm)
You can even use a schedule interval of 0 (zero) in this case.What's happening is that when you call loadlevel, and therefore unloadlevel from within a scope that depends on an object that gets unloaded, and follow-on references (script or engine internal c++) now has an undefined reference to an object (since you unloaded the object).
a schedule of zero duration simply sets the function to be scheduled to occur the very next time we are at a "safe" scoping level, thereby avoiding the possibility of deleting objects "out from underneath" the code they are using.
Torque Owner Drew -Gaiiden- Sikora