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)