In my game there are balls falling from the sky and you try to dodge them with the white ball, as seen in the attachment. The white ball is moved by tilting the screen, and the balls go towards the direction you tilt you device. here is my code:
[lua]
local function onAccelerate( event )
print(event.yGravity)
player.x = player.x - (event.yGravity*10)
end
function scene:createScene( event )
group = self.view
player = display.newImageRect(“game_player.png”,67,67)
player.x = display.contentWidth - 25
player.y = ground2.y - 61
player:scale(.63,.63)
physics.addBody(player, “static”, { radius = 12 } )
player.collision = playerCollision
player:addEventListener(“collision”, player)
group:insert(player)
end
function scene:enterScene( event )
local group = self.view
Runtime:addEventListener( “accelerometer”, onAccelerate )
end
[/lua]
With the following code, whenever I tilt my device, instead of a smooth flowing motion of the ball I get a jittery, un-smooth effect where it looks like the ball is moving transporting itself forward instead of rolling. How do I change/edit my code so that the ball rolls smoothly? Thank you.