Hi!
In the game I’m currently working on, you need to drag arbitrarily shaped objects onto a playing field. So far no problems. But, I want to check if the object I’m dragging overlaps another object.
After scouring the forums etc I’ve found no satisfying solution. Checking bounding boxes is not accurate enough since I want the player to be able to drag objects into the nooks and crannies of already placed objects, as it were. Imagine placing a circular object in the space between two arbitrarily rotated cross-shaped objects for example.
I’ve tried using an invisible collision detection object added to the physics engine with the isSensor flag set to true, trying to take advantage of the collision detection that is provided by the engine and it almost works… The problem is that the collision system is event-based which works very well in most cases but what I’d like to do is to poll the system if an object is colliding with or overlapping another object.
The following code almost does the job, except that the “ended” phase fires even if the objects are still overlapping so it’s not accurate enough.
[lua]function collisionDetector:collision( event )
if event.phase == “began” then
print(“collision began”)
self:setFillColor( 255, 0, 0 );
elseif event.phase == “ended” then
print(“collision ended”)
self:setFillColor(0, 255, 0)
end
return true
end[/lua]
I’d like to have a checkLegalPosition function that fires on the touch-event’s move phase that returns false if two objects are overlapping.
Hope you guys can help 
Cheers
/Daniel [import]uid: 45930 topic_id: 9386 reply_id: 309386[/import]