Hey guys!
We’re having a problem in making a “flick” function. It works as expected when you do long, drawn out flicks, or when you drag and release. However, if you actually flick, the ball that you’re flicking drops, because the event never ends.
function flick(event) count = 0 if event.phase == "began" then physics.setGravity(0,0) startX = event.x startY = event.y physics.addBody(ball, "dynamic", {friction=1, bounce = 0.3, radius=30, isSleeping = false,filter = {maskBits = 10, categoryBits = 4}}) elseif event.phase == "moved" then --dragging the ball if not x1 then x1 = display.contentCenterX end if not y1 then y1 = display.contentCenterY end x2 = x1 y2 = y1 x1 = event.x y1 = event.y ball.x = event.x ball.y = event.y physics.setGravity(0,0) elseif event.phase == "ended" then --applying force on the ball local a = 3 ball:applyForce(a\*(x1-x2), a\*(y1-y2), ball.x, ball.y) end physics.setGravity(0,18) end
We can’t think of any reason this should be happening. Anyone else experience similar things and/or have a fix to this problem?
Thanks!