transition.to and physics question

i’ve got this little snippet that doesn’t seem to work right. it does make my ball jump up on tap, but with more taps it seems the ball is getting heavier and after about 10-15 taps, falls to the ground almost instantly. Seems like the gravity is increasing, or some variable is at the very lease. Does anyone know what the problem with it is? Thx

–Add physics

local physics = require “physics”

physics.start()

–Background settings

local bg = display.newImage(“bg.png”)

–Floor

local floor = display.newRect(display.contentWidth, display.contentHeight, display.contentWidth * 2, 5)

physics.addBody(floor, “static”, { density = 1, friction = 1, bounce = 0 } )

local ball = display.newImage(“ball.png”)

ball.x = display.contentWidth/2 - 100

ball.y = display.contentHeight/2

physics.addBody(ball, { density = 0, friction = 1, bounce = 1 } )

–Screen tap settings

local tapArea = display.newRect(0, 0, display.contentWidth * 2, display.contentHeight * 2)

tapArea.alpha = .1

local function screenTap (event)

    

    

    if ball.y > 20 then

        transition.moveTo(ball, {time=transitionTime, x=ball.x, y=ball.y - 50})

    end

end

tapArea:addEventListener (“tap”, screenTap)

Transitions and physics don’t mix well.

What you want to do is apply a force to the ball: http://docs.coronalabs.com/api/type/Body/applyLinearImpulse.html

Probably also a good idea to have a density > 0 on your ball.

Using applyLinearImpulse did make it fall back down at constant speed, but multiple taps add more and more force to the ball. So now several taps make it jump off screen. Is there a way to make the jumps more uniform and even? Thx

Transitions and physics don’t mix well.

What you want to do is apply a force to the ball: http://docs.coronalabs.com/api/type/Body/applyLinearImpulse.html

Probably also a good idea to have a density > 0 on your ball.

Using applyLinearImpulse did make it fall back down at constant speed, but multiple taps add more and more force to the ball. So now several taps make it jump off screen. Is there a way to make the jumps more uniform and even? Thx