After trying to solve this issue for quite some time, I’ve searched these forums as well as other Lua sites intensively to find exactly what I’m looking for. I’ve found code that is close but does not do what I require.
Collision on the object is not the problem, it’s detecting where on the object it has been hit. There is code for this, however it only works on stationary objects. I need this working on a moving object.
Example is a top down maze game. I need to determine when the moving player collides with a wall either on the top, bottom, left, or right.
I’ve worked with this code that I’ve found on these forums, I’ve modified it heavily (not shown) but the code does not work on a moving object, produces incorrect results due to placement within the maze.
Original Example:
function displayObj:collision( event )
if (event.phase == "began") then
if (event.other.x \< displayObj.x) then
-- object collided with was on left on this object
elseif (event.other.x \> displayObj.x) then
-- object collided with was on right of this object
end
end
end
http://developer.anscamobile.com/forum/2010/12/14/detecting-collision-left-side-right-side-object
Any assistance on this would be greatly appreciated
[import]uid: 40758 topic_id: 27072 reply_id: 327072[/import]