I made a canvas with shapes in it...the shapes are draggable. Everything seems to work fine...But now I\'m trying to figure out how can I detect what shape was selected/drag
I found pretty simple solution...but I guess that's the way it always works :-) All you have to do for the detection is 2 things: First of all add another variable: var thisObject; After that you have to go to the onMouseDown() function. Right after the SELECTED = intersects[0].object; you have to write this thing:
for(var i=0; i<objects.length; i++)
{
if(SELECTED.position.x == objects[i].position.x)
thisObject = i;
}
...Now thisObject holds the index of the current shape (that was selected/dragged) in objects array...yeah that simple :-)