object schedules getting reloaded in new level
by Aditya Kulkarni · in Torque Game Builder · 02/18/2010 (9:02 am) · 2 replies
I have this function which clears up everything in a level.
But when I load another level, the schedules are still not canceled and leads to more(undesired) objects to be added to the new scene after completion.
Question 1:
Shouldn't the schedules automatically get canceled when the object is deleted?
Question 2:
I explicitly canceled all object schedules in the function shredObj, so why are they still in the new scene?
function cleanUp() {
%count = $levelObjSimset.getCount();
for(%i=0;%i<%count;%i++) {
%objId = $levelObjSimset.getObject(%i);
shredObj(%objId);
}
$levelObjSimset.clear();
$levelObjSimset.delete();
$levelObjSimset = new SimSet(levelObjSimset);
}
function shredObj(%objId) {
%parent = %objId.name;
cancel(%parent.growingHandleAlpha);
cancel(%parent.growingHandle);
%parent.icon1.safeDelete();
%parent.icon2.safeDelete();
%parent.icon3.safeDelete();
%parent.icon4.safeDelete();
if(isObject(%parent)&&stricmp(%parent.class,"waterbody")) {
%cnt = 0;
%wp = %parent.base.position;
%tp = tilemap1.pickTile(%wp);
tilemap1.setTileCustomData(%tp, "0");
for(%i=0;%i<21;%i++) {
%wp = %parent.base[%cnt].position;
%tp = tilemap1.pickTile(%wp);
tilemap1.setTileCustomData(%tp, "0");
%parent.base[%i].safeDelete();
%cnt++;
}
%clones = %parent.clones;
//echo ("Clones: "@%clones);
//echo ("Deleted Object: "@$prevObject);
for(%i=0;%i<%clones;%i++) {
%parent.bluebg[%i].safeDelete();
}
}
%parent.removeFromScene();
%parent.safeDelete();
sceneWindow2D.remove(%obj);
}But when I load another level, the schedules are still not canceled and leads to more(undesired) objects to be added to the new scene after completion.
Question 1:
Shouldn't the schedules automatically get canceled when the object is deleted?
Question 2:
I explicitly canceled all object schedules in the function shredObj, so why are they still in the new scene?
#2
SceneWindow2D.endLevel($lastLoadedScene) has no effect whatsoever. Doing levelName.endLevel() fixed it.
02/19/2010 (8:47 am)
Solved.SceneWindow2D.endLevel($lastLoadedScene) has no effect whatsoever. Doing levelName.endLevel() fixed it.
Torque 3D Owner Matthew Langley
Torque
isEventPending( eventID )
checks after the objects are deleted and at different points to see if they are actually getting nuked.