better simple collision approach between two bodies or multiple

hi, i am making a game in which a person is hit by bird, any how the bird just goes back and the person loses some points. it my first game so far.

now every thing is ready and there comes the issue of collision, i read and read and found that collision is detected using physics. but i was wodering if i can make it by any simple approach. as trying with the physics collides them and they behave like real objects and change direction and fall flat to the ground.

QUESTION:

what is the simplest approach to find if object A and object B crossed each other at certain area. i can do it by matching like

if obj1.x ==obj2.x then

do this and that

but that will be too precise to match i want to detect a certain range like a radiuses crossing each other or the object itself if can be detected…i dont know how to address the better approach

If you don’t want to use physics, you can either use a radius or bounding box test in an Runtime “enterFrame” listener to watch for objects overlapping.

See  https://coronalabs.com/blog/2013/07/23/tutorial-non-physics-collision-detection/

However if you want the bird to hit the object, and fall to the ground, sounds like you need to use physics.

Rob

A real simple check, assuming you have very simple objects is this…  Assuming each object is 10px wide centred at x,y then you could say a collision has happened if

if math.abs(obj1.x - obj2.x) \<= 10 and math.abs(obj1.y - obj2.y) \<= 10 then --has hit end

copied–>pasted and it worked, i added it to the runtime event of enter frame, is it fine there ? it works now, i can create a function with multiple checks and it will detect all the collisons there…thanks bro…thanks a lot

If you don’t want to use physics, you can either use a radius or bounding box test in an Runtime “enterFrame” listener to watch for objects overlapping.

See  https://coronalabs.com/blog/2013/07/23/tutorial-non-physics-collision-detection/

However if you want the bird to hit the object, and fall to the ground, sounds like you need to use physics.

Rob

A real simple check, assuming you have very simple objects is this…  Assuming each object is 10px wide centred at x,y then you could say a collision has happened if

if math.abs(obj1.x - obj2.x) \<= 10 and math.abs(obj1.y - obj2.y) \<= 10 then --has hit end

copied–>pasted and it worked, i added it to the runtime event of enter frame, is it fine there ? it works now, i can create a function with multiple checks and it will detect all the collisons there…thanks bro…thanks a lot