I have two separate algorithms that detect collisions between rectangles and circles. The images I’m using have a custom shape, thus collisions are being detected even though the images aren’t touching each other. Does anybody have an algorithm that detects collisions between objects with a custom shape? Or is there a way I can use physics without altering the objects position because I’m currently using transition.to for my animations.
Here is the algorithm I’m using for the collision detection
local function hasCollided( obj1, obj2 ) if ( obj1 == nil ) then --make sure the first object exists return false end if ( obj2 == nil ) then --make sure the other object exists return false end local left = obj1.contentBounds.xMin \<= obj2.contentBounds.xMin and obj1.contentBounds.xMax \>= obj2.contentBounds.xMin local right = obj1.contentBounds.xMin \>= obj2.contentBounds.xMin and obj1.contentBounds.xMin \<= obj2.contentBounds.xMax local up = obj1.contentBounds.yMin \<= obj2.contentBounds.yMin and obj1.contentBounds.yMax \>= obj2.contentBounds.yMin local down = obj1.contentBounds.yMin \>= obj2.contentBounds.yMin and obj1.contentBounds.yMin \<= obj2.contentBounds.yMax return (left or right) and (up or down) end