Collision detection without physics

hey,

I’m trying to create a function that lets me know when two specific object have been colliding. The physics was giving me a hard time doing that because one of the objects is affected by transition of scale when the touch event is triggered.

I tried to follow a guide that instructed how to do so without physics, but it doesnt really work. I wonder if anyone can point me in the right direction?

**module(…,package.seeall);

function newCrate()

crateNormal=display.newImage(“crate.png”)
crateNormal.width = 50
crateNormal.height= 50
crateNormal.y=-30
crateNormal.x= math.random(50,900)
crateNormal.rotation=50
physics.addBody(crateNormal, “dynamic”, {bounce=0.5})

function hasCollidedCircle(obj1, obj2)
    local sqrt = math.sqrt
    local dx =  obj1.x - obj2.x;
    local dy =  obj1.y - obj2.y;    
    local distance = sqrt(dx*dx + dy*dy);
    local objectSize = (obj2.contentWidth/2) + (obj1.contentWidth/2)
    if distance < objectSize then
        print(“good”)
        else
    print(“not good”)
    end
end

function testCollisions()
         hasCollidedCircle(crateNormal,ball)
end

Runtime:addEventListener(“enterframe”, testCollisions)
return crateNormal
end
end**

the “ball” object is in the main.lua

Here is a good article from Rob Miracle:

http://omnigeek.robmiracle.com/2011/12/14/collision-detection-without-physics/

Here is a good article from Rob Miracle:

http://omnigeek.robmiracle.com/2011/12/14/collision-detection-without-physics/