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)