So I am currently trying to get collision between 2 sprites working without using the corona physics system. I cannot use the corona physics because my sprites are not square and I do need to rotate them on occasion, which this physics system doesn’t understand.
My two sprites are made from sprite sheets, and the logic I am trying to follow is that if an edge of a sprites overlaps an edge of the other sprite then we have collision, sounds simple but doesn’t seem to work.
if(spriteObject.x - spriteObject.contentWidth / 2 \>= richInstance1.x + richInstance1.contentWidth / 2 and spriteObject.x - spriteObject.contentWidth / 2 \< richInstance1.x - richInstance1.contentWidth / 2) then
print("pre collision hit")
if(spriteObject.y + spriteObject.contentHeight / 2 \>= richInstance1.y - richInstance1.contentHeight / 2 and spriteObject.y + spriteObject.contentHeight / 2 \< richInstance1.y + richInstance1.contentHeight / 2) then
print("collision with ball")
elseif(spriteObject.y - spriteObject.contentHeight / 2 \<= richInstance1.y + richInstance1.contentHeight / 2 and spriteObject.y - spriteObject.contentHeight / 2 \> richInstance1.y - richInstance1.contentHeight / 2) then
print("collision with ball")
end
end
[import]uid: 105311 topic_id: 21677 reply_id: 321677[/import]
[import]uid: 52491 topic_id: 21677 reply_id: 86267[/import]