Never mind, I fixed it. I adjusted the values in the function and it worked perfectly.
My display object was 115 x 115 pixels, but I only wanted it to be detected in the non-physics based collision function as if it were 35 x 35 pixels. This is the revised function (in case anyone else needs a fix like this):
[lua]
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
if (obj1.contentBounds == nil) then
return false
end
if (obj2.contentBounds == nil) then
return false
end
local left = obj1.contentBounds.xMin + 40 <= obj2.contentBounds.xMin and obj1.contentBounds.xMax - 40 >= obj2.contentBounds.xMin
local right = obj1.contentBounds.xMin + 40 >= obj2.contentBounds.xMin and obj1.contentBounds.xMin + 40 <= obj2.contentBounds.xMax
local up = obj1.contentBounds.yMin + 40 <= obj2.contentBounds.yMin and obj1.contentBounds.yMax - 40 >= obj2.contentBounds.yMin
local down = obj1.contentBounds.yMin + 40 >= obj2.contentBounds.yMin and obj1.contentBounds.yMin + 40 <= obj2.contentBounds.yMax
if (left == nil) then
return false
end
if (right == nil) then
return false
end
if (up == nil) then
return false
end
if (down == nil) then
return false
end
return (left or right) and (up or down)
end
[/lua]
Thanks for all your help, Brent.