Which one is better?

I am trying to make a video game where collision is an important part.Since my game is very complex what collision detection type is better?

The Non physics collision (see the code) ? Or preCollision and postCollision  (see the link for example)  http://docs.coronalabs.com/daily/guide/physics/collisionDetection/index.html?)

Thanks!

function hasCollidedGround (event) if ball == nil then return false end if ground == nil then return false end local up = ball.contentBounds.yMin \<= ground.contentBounds.yMin and ball.contentBounds.yMax \>= ground.contentBounds.yMin local down = ball.contentBounds.yMin \>= ground.contentBounds.yMin and ball.contentBounds.yMin \<= ground.contentBounds.yMax return (up or down) end function endCollisionGround (event) if ball == nil then return false end if ground == nil then return false end local up = ball.contentBounds.yMin ~= ground.contentBounds.yMin and ball.contentBounds.yMax ~= ground.contentBounds.yMin local down = ball.contentBounds.yMin ~= ground.contentBounds.yMin and ball.contentBounds.yMin ~= ground.contentBounds.yMax return (up or down) end function hasCollidedWall (event) if ball == nil then return false end if wall == nil then return false end local up = ball.contentBounds.yMin \<= wall.contentBounds.yMin and ball.contentBounds.yMax \>= wall.contentBounds.yMin local down = ball.contentBounds.yMin \>= wall.contentBounds.yMin and ball.contentBounds.yMin \<= wall.contentBounds.yMax return (up or down) end function endCollisionwall (event) if ball == nil then return false end if ground == nil then return false end local up = ball.contentBounds.yMin ~= wall.contentBounds.yMin and ball.contentBounds.yMax ~= wall.contentBounds.yMin local down = ball.contentBounds.yMin ~= wall.contentBounds.yMin and ball.contentBounds.yMin ~= wall.contentBounds.yMax return (up or down) end function onCollisionGround(event) if hasCollided (ball,ground) then if beam.isVisible == true print ("collision started with the ground") if endCollision(ball,ground) print ("collision ended ") end end end Runtime:addEventListener ("enterFrame",onCollisionGround) function onCollisionWall(event) if hasCollided (ball,wall) then if beam.isVisible == true then print ("collision started with the wall") if endCollision(ball,wall) print ("collision ended ") end end Runtime:addEventListener ("enterFrame",onCollisionWall)

Hi @bogdanmocanu2,

This question is hard to answer. Will your objects potentially collide with several other objects? Will any of these object be “complex in shape”, as in, not rectangular? If so, then you should probably use physics-based collisions, which are significantly more advanced/detailed and provide you with a ton of options.

Brent

Hi Brent,

 And regarding the performance?

Depends on your answers to Brent’s questions.

Yes my objects will colide with another object,a rectangle and they have complex shapes.

OK, if you’re going to deal with complex shapes and the collisions must match these shapes closely, then you should definitely use physics. Performance will be fine in this regard (using physics).

Brent

Thank you!

Hi @bogdanmocanu2,

This question is hard to answer. Will your objects potentially collide with several other objects? Will any of these object be “complex in shape”, as in, not rectangular? If so, then you should probably use physics-based collisions, which are significantly more advanced/detailed and provide you with a ton of options.

Brent

Hi Brent,

 And regarding the performance?

Depends on your answers to Brent’s questions.

Yes my objects will colide with another object,a rectangle and they have complex shapes.

OK, if you’re going to deal with complex shapes and the collisions must match these shapes closely, then you should definitely use physics. Performance will be fine in this regard (using physics).

Brent

Thank you!