lua - 3 point object moving is happening all at once -


i making jumping game there object @ left side of screen, on platform. once object jumps , lands on platform on right, following:

1) platform on right moves left

2) platform on left (that jumped off from) moves off-screen.

3) new platform supposed appear @ right side of screen, continuing loop.

i have made functions allows object jump , show if collision successful or not. problem is, 3 things have mentioned above happens, keeps on going , not stop object make next jump. makes object go off screen well, since platforms keep moving towards left. after debugging, feel problem lies collision happens. because, once touches platform, collision keeps on happening until object off of platform. wondering if guys can me this!

here part of code relevant:

local onplatform = false local gamestarted = false   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   function movecolumns()         = elements.numchildren,1,-1               --speed of columns moving             --if greater -100, keep moving left             --puts platform @ right , stops             if (elements[a].x > display.contentwidth/1.1)                 elements[a].x = elements[a].x - 12             end             --moves platform left after lands             if (onplatform == true)                 if (elements[a].x > display.contentwidth/3 , elements[a].x < display.contentwidth/1.11)                     elements[a].x = elements[a].x - 12                 end             end             --moves left platform off-screen , deletes after passes x-axis             if (onplatform == true)                 if(elements[a].x > -100 , elements[a].x < display.contentwidth/2.99)                     elements[a].x = elements[a].x - 12              --adds score if goes past x-axis @ left side                 elseif(elements[a].x < -100)                 mydata.score = mydata.score + 1                 tb.text = mydata.score                 elements[a].scoreadded = true                  elements:remove(elements[a])                 elements[a] = nil                 end             end          end end 

when calling movecolumns?? call within playercollision , remove onplatform variable? need bit more code properly.


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 -