lua - Event.target collides only once, not multiple times -
when run oncollision function, seems collides 'ground' multiple times, though not moving. how can make once object hits ground, collides 'once'?
i give 'score' every time hits ground, because hits ground multiple times, score seems keep going up.
here part of code:
function playercollision( self, event ) if ( event.phase == "began" ) --if hit bottom column, u points if event.target.type == "player" , event.other.type == "bottomcolumn" print ("hit column") onplatform = true else --if hit else, gameover --composer.gotoscene( "restart" ) print ("hit ground") end end end
i didnt find wrong code, try add statement, hope may work.
function playercollision( self, event ) if ( event.phase == "began" ) --if hit bottom column, u points if event.target.type == "player" , event.other.type == "bottomcolumn" print ("hit column") onplatform = true return true -- try adding else --if hit else, gameover --composer.gotoscene( "restart" ) print ("hit ground") end end
end
Comments
Post a Comment