Game Development Community

How do I get scene object without using collision?

by Jereis Zaatri · in iTorque 2D · 12/19/2010 (6:19 pm) · 3 replies

Is there a way to get scene object if I provide an x, y coordinate? Using onMousePress() call backs won't work, because my GUI objects take up the whole screen, so I need something that I can accomplish with coordinates only. Is there a way, I can produce a "fake" mouse press the bypasses the gui layer?

#1
12/19/2010 (9:48 pm)
If you have an x,y coordinate, try calling the pickPoint method from the currentScenegraph

// Get the scene graph
%sceneGraph = sceneWindow2D.getSceneGraph();

// Use separate coordinate variables
%x = 0.0;
%y = 1.0;

// Return a list of object IDs that fall in the picked point
%foundObjects = %sceneGraph.pickPoint(%x, %y);

// Use a single coordinate string
%coordinates = "0.0 1.0"

// Return a list of object IDs that fall in the picked point
%foundObjects = %sceneGraph.pickPoint(%coordinates);

You might also be interested in pickRadius(...) and pickRect(...).
#2
12/19/2010 (9:56 pm)
Do the pick calls select based on the visual dimensions of the object or it's collision space?

Thanks!
#3
12/19/2010 (10:02 pm)
I believe it will obey physics properties first (collision attributes), then go visual if none exists. The start of the function is in t2dSceneGraph.cc if you want to check it out.