3 point object moving is happening all at once

Hi guys!

I am currently making a jumping game where there is an object at the left side of the screen, on a platform. Once the object successfully jumps and lands on the platform on the right, it does the following:

  1. the platform on the right moves to the left 

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

  3. a new platform is supposed to appear at the right side of the screen, thus continuing the loop. 

I have already made the functions where it allows the object to jump and show if the collision is successful or not. My problem is, the 3 things I have mentioned above happens, but it keeps on going and does not stop for the object to make the next jump. This makes the object go off screen as well, since the platforms keep moving towards the left. After debugging, I feel like the problem lies where the collision happens. This is because, once it touches the platform, the collision keeps on happening until the object is off of the platform. I was wondering if you guys can help me with this!

Here is part of my code that is relevant:

  

&nbsp; local onPlatform = false &nbsp; local gameStarted = false &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;function playerCollision( self, event ) &nbsp; &nbsp; if ( event.phase == "began" ) then &nbsp; &nbsp; --if hit bottom column, u get points &nbsp; &nbsp; if event.target.type == "player" and event.other.type == "bottomColumn" then &nbsp; &nbsp; print ("hit column") &nbsp; &nbsp; onPlatform = true &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; else &nbsp; &nbsp; --if hit anything else, gameOver &nbsp; &nbsp; --composer.gotoScene( "restart" )&nbsp; &nbsp; &nbsp; print ("hit ground") &nbsp; &nbsp; end &nbsp; &nbsp; end &nbsp; end function moveColumns() &nbsp; &nbsp; for a = elements.numChildren,1,-1 &nbsp;do &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; --speed of columns moving &nbsp; &nbsp; --if greater than -100, keep moving it to left &nbsp; &nbsp; --puts platform at the right and stops &nbsp; &nbsp; if (elements[a].x \> display.contentWidth/1.1) then &nbsp; &nbsp; elements[a].x = elements[a].x - 12 &nbsp; &nbsp; end &nbsp; &nbsp; --moves platform to left after it successfully lands &nbsp; &nbsp; if (onPlatform == true) then &nbsp; &nbsp; if (elements[a].x \> display.contentWidth/3 and elements[a].x \< display.contentWidth/1.11) then &nbsp; &nbsp; elements[a].x = elements[a].x - 12 &nbsp; &nbsp; end &nbsp; &nbsp; end &nbsp; &nbsp; &nbsp;--moves left platform to off-screen and deletes after it passes a certain X-axis &nbsp; &nbsp; if (onPlatform == true) then &nbsp; &nbsp; if(elements[a].x \> -100 and elements[a].x \< display.contentWidth/2.99) then &nbsp; &nbsp; elements[a].x = elements[a].x - 12 &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; --adds score if it goes past a certain X-axis at left side &nbsp; &nbsp; elseif(elements[a].x \< -100) then &nbsp; &nbsp; mydata.score = mydata.score + 1 &nbsp; &nbsp; tb.text = mydata.score &nbsp; &nbsp; elements[a].scoreAdded = true &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; elements:remove(elements[a]) &nbsp; &nbsp; elements[a] = nil &nbsp; &nbsp; end &nbsp; &nbsp; end &nbsp; &nbsp; end &nbsp; end

Hi @hyeonjun93,

I responded to your other post which should help you solve this.

Brent

Hi @hyeonjun93,

I responded to your other post which should help you solve this.

Brent