I am trying to create a doodle jump clone for practice. Right now I have a ball that when the screen is clicked is given a linear impulse, travels up through platforms and then lands on top of the platform it just passed through. This is step 1 for me. I would like the ball to have a linear impulse applied to it when it touches down on the platform that it had just passed through, but I am having some issues. This is step 2.
Is it wrong to try and achieve step 2 in my collision function? As of right now the ball does not land on top of the platform after it passes through, it goes below out the bottom of the platform and bounces up on nothing.
function ball:preCollision( event ) if ( event.other.collType == "passthru" ) then local char = self.y local plat = event.other.y if ( char \> plat) then event.contact.isEnabled = False self.isSensor = true ; self.setAsSensor = true end end end ball:addEventListener( "preCollision" ) function ball:collision( event ) local vx,vy = self:getLinearVelocity() if ( event.phase == "began" ) then local collType = event.other.collType elseif ( event.phase == "ended" ) then if vy \> 0 then self.isSensor = false ; self.setAsSensor = false self:setLinearVelocity(0, -650) end end end ball:addEventListener( "collision" )