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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -