hi,my question is very basic.
i am having a problem with applying a constant force to an abject.what i want is that whenever
i tap on screen,the object should get a fixed force of -50 pixels vertically.
i experimented with both applyLinearImpulse and applyForce but result i am getting is quite weird.
my code looks like this
local centerX=display.contentWidth\*0.5; local centerY=display.contentHeight\*0.5; local physics=require("physics"); physics.start() physics.setGravity( 0, 40) ------------ ball=display.newImageRect("ball.png",30,30); ball.x=centerX-140; ball.y=centerY; physics.addBody(ball, "dynamic",{density=.1, bounce=0.1, friction=1}); ------------ local function flyUp(event) if event.phase == "began" then ball:applyForce(0, -50, ball.x, ball.y) end end Runtime:addEventListener("touch", flyUp)
sometimes when i tap i get a very little force and sometimes a high force.
what can i do so that they ball gets exactly -50 pixels upward whenever i tap??