Finding object
by JD Scogin · in Torque Game Builder · 08/31/2007 (6:37 am) · 3 replies
I have a screen that is dynamically generated. There are many objects of different types.
Is there a way, by using coordinates to see what object is at a location?
I am not using tiles (maybe I should).
Thanks
Jd
Is there a way, by using coordinates to see what object is at a location?
I am not using tiles (maybe I should).
Thanks
Jd
About the author
#2
08/31/2007 (9:06 pm)
Here is some code that goes through all the objects in a scenegraph and checks for object classfunction checkMiss(%worldPos)
{
%objList = SceneWindow2D.getScenegraph().pickPoint(%worldPos);
%objCount = getWordCount(%objList);
%selObj = true;
//we will start looping through the list
for(%i=0;%i<%objCount;%i++)
{
%obj = getWord(%objList, %i);
if(%obj.class $= "Mole" || %obj.class $= "Bonus" || %obj.class $= "Health")
{
%selObj = false;
break;
}
}
if ( %obj.class $= "Mole" && %obj.getAnimationName() $= $etype_anim_blink_2[%obj.etype] )
{
%selObj = true;
}
return %selObj;
}
#3
I wonder what the next obstacle will be.
I sure do ask a lot of questions, but I always get answers!
09/01/2007 (5:34 am)
Thanks to both. This will make my game work!I wonder what the next obstacle will be.
I sure do ask a lot of questions, but I always get answers!
Torque Owner Spider