Hello i can’t seem to get the accelerometer tilt motion to work like it does on the game “Tilt Monster”… what i’m I doing wrong here ??
[code]
display.setStatusBar (display.HiddenStatusBar)
–> Hides the status bar
local physics = require (“physics”)
physics.start()
physics.setGravity(0,0)
–> start physics engine and set the gravity (I’m using 0 to start, you might want to change this.)
background = display.newImage (“background.png”)
–> Sets the background
ball = display.newImage (“ball.png”)
ball.x = 160
ball.y = 200
physics.addBody(ball, {friction = 1.0, bounce=0.6})
–> Adds the ball and adds physics to the ball
local motionx = 0
local motiony = 0
local function onAccelerate( event )
motionx = 35 * event.xGravity
motiony = 35 * event.yGravity
end
Runtime:addEventListener (“accelerometer”, onAccelerate)
local function moveball (event)
ball.x = ball.x + motionx
ball.y = ball.y - motiony
end
Runtime:addEventListener(“enterFrame”, moveball)
[/code] [import]uid: 45615 topic_id: 10578 reply_id: 310578[/import]