COLLISION

Hy guys… 

I make a flappy bird clone but i have a problem with collision detection… my charapter collide before touch ground… 

my code is this 

function onCollision( event ) if ( event.phase == "began" ) then composer.gotoScene( "restart",options ) end end

in screenshoot attachment you can see when collision began … why?.. 

thanks in advice 

You’ll have to show the pertinent code.  What you posted doesn’t give details of the problem

Please read your logs. https://docs.coronalabs.com/guide/basics/debugging/index.html#consoledebugging

If you read them, I am pretty sure you will get a warning saying that physics bodies can not be removed while in a collision. My guess is somewhere in your code when scene:hide or scene:destroy is called you remove the physics bodies. Now as soon as the physics engine detects a collision(in your onCollision function), you call gotoScene which triggers your scene:hide and then if you have a removeScene call it triggers scene:destroy. And due to limitations of the physics engine, you can’t remove physics bodies mid-collision. My guess is that is the problem. You will have to post more code, especially if you are using removeScene call.

Edit: IF this is indeed the problem, the solution is to set a timer.performWithDelay on the gotoScene function.

You’ll have to show the pertinent code.  What you posted doesn’t give details of the problem

Please read your logs. https://docs.coronalabs.com/guide/basics/debugging/index.html#consoledebugging

If you read them, I am pretty sure you will get a warning saying that physics bodies can not be removed while in a collision. My guess is somewhere in your code when scene:hide or scene:destroy is called you remove the physics bodies. Now as soon as the physics engine detects a collision(in your onCollision function), you call gotoScene which triggers your scene:hide and then if you have a removeScene call it triggers scene:destroy. And due to limitations of the physics engine, you can’t remove physics bodies mid-collision. My guess is that is the problem. You will have to post more code, especially if you are using removeScene call.

Edit: IF this is indeed the problem, the solution is to set a timer.performWithDelay on the gotoScene function.