Hi Ho folks,
I’m trying to check if two objects have collided when I release my finger after I’ve dragged an object around. (Essentially did I leave one object over another?)
I setup Physics.addbodies and they collide fine but I need to reference that they are still colliding or only check if they are colliding when I release my finger. (during my Drag Functions event.phase == “ended” )
I’m not sure what to check for or fire off a collision at that end phase of the drag. if that’s what I need to do.
Any help is appreciated.
Here’s a simplified code:
local function onCollision( event ) if ( event.phase == "began" ) then -- these 2 objects are touching check print(event.target.ID .. " and " .. event.other.ID) return true end end -- touch listener function onTouch = function( event, collision) local self = event.target local phase = event.phase if "began" == phase then print("Pressed") --Drag code remove for ease. elseif "ended" == phase or "cancelled" == phase then if( --- TRY TO CHECK IF COLLISION IS OCCURING HERE --- ) then print("wow object1 and object 2 are colliding") ... Do Stuff end display.getCurrentStage():setFocus( nil ) self.isFocus = false end end end Object1:addEventListener("collision", onCollision) Object1:addEventListener( "touch", onTouch) ... and other objects