Deleting SimSet (unable to find objects)
by Mr Zurkon · in iTorque 2D · 07/04/2011 (10:32 am) · 7 replies
Function that creates the objects:
I'm able to call $mySimSet.getCount() and get an accurate count. However, when I attempt to delete the group a line later using $mySimSet.delete() I get "unable to find object". If the earlier function is able to find the simset (and count the objects within), then why can't it delete it as well? Am I using the wrong function?
function testSpawn(%scenegraph) {
%rock = new t2dStaticSprite(RockA) {
imageMap = "rock01";
frame = "0";
UsesPhysics="1";
mUseSourceRect = "0";
sourceRect = "0 0 0 0";
canSaveDynamicFields = "1";
Position = "-90.349 -33.945";
size = "100.000 47.000";
CollisionMaxIterations = "3";
WorldLimitMode = "NULL";
WorldLimitCallback = "1";
WorldLimitMin = "-321.426 -185.000";
WorldLimitMax = "320.000 300.116";
mountID = "4";
};
$MySceneGraph.addToScene(%rock);
$mySimSet.add(%rock);
}I'm able to call $mySimSet.getCount() and get an accurate count. However, when I attempt to delete the group a line later using $mySimSet.delete() I get "unable to find object". If the earlier function is able to find the simset (and count the objects within), then why can't it delete it as well? Am I using the wrong function?
#2
i don't think there's anything wrong with the declaration. if there was, why would $mySimSet.getCount() work?
07/04/2011 (6:41 pm)
it's declared at the beginning of the game.cs script along with some other global variables. i don't think there's anything wrong with the declaration. if there was, why would $mySimSet.getCount() work?
#3
07/05/2011 (4:44 am)
Are you trying to delete the rock object? $mySimSet.delete(); would delete the simset, not the rock. You need to write something like the following:%rock = $mySimSet.getObject(0); // Get rock object $mySimSet.remove(%rock); // Remove rock from SimSet %rock.delete(); // Delete the rock object
#4
07/05/2011 (6:14 am)
I'm trying to mass-delete objects I've put in a SimSet, instead of having to delete them individually. I'm trying to find the documentation I was looking at when writing this. Are there other solutions I can use?
#5
07/05/2011 (6:18 am)
Just put that in a loop thenwhile($mySimSet.getCount() > 0)
{
%rock = $mySimSet.getObject(0); // Get rock object
$mySimSet.remove(%rock); // Remove rock from SimSet
%rock.delete(); // Delete the rock object
}
$mySimSet.delete();
#6
thanks!
07/05/2011 (6:40 am)
...i should have just done that right away. :) i'm still a bit curious why I couldn't find the objects, but I'll leave that to another time.thanks!
#7
Would $mySimSet.clear() automatically delete all objects in the set or simply remove them from the set but they still exist? Would simply using $mySimSet.clear() cause a memory leak? I can't seem to find the official documentation for this.
09/20/2011 (2:27 am)
Platform: iTorque 1.4.Would $mySimSet.clear() automatically delete all objects in the set or simply remove them from the set but they still exist? Would simply using $mySimSet.clear() cause a memory leak? I can't seem to find the official documentation for this.
Torque 3D Owner Matt Huston
Atomic Banzai Games
You need $mySimSet = new SimSet(); somewhere