How to change the accelerometer to be faster...

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]

well you can increase the 35 to 45 or 55 at motionx and motion y

local function onAccelerate( event )
motionx = 35 * event.xGravity
motiony = 35 * event.yGravity
end [import]uid: 7427 topic_id: 10578 reply_id: 38501[/import]

You could setting the accelerometer by using: system.setAccelerometerInterval( x ). [import]uid: 23649 topic_id: 10578 reply_id: 39267[/import]

it seems to be a delay once it hits the sides… [import]uid: 45615 topic_id: 10578 reply_id: 39555[/import]

It’s hard to comment on the sides issue because I don’t see the code for that. I’m not sure this is the best/most efficient way of doing things but you could try just letting physics/gravity move the ball on it’s own by replacing move ball/on accelerate with something like:

physics.setGravity(x*event.xGravity,-x*event.yGravity)

It’s what I did in the one game I currently have released and it worked pretty well for me.

If you can share the code for the sides that would help. [import]uid: 23649 topic_id: 10578 reply_id: 39557[/import]

The code is the same one above… As soon the ball hits the wall (one side) there is a delay on the opposite movement, so for example if you till left and it hits the wall there is a delay when tilling right and the same goes the other way around… But i will try what you are using… If i can get it to work… I’m new to this and know nothing… Still learning. just wish these community was more active, is kinda dead… [import]uid: 45615 topic_id: 10578 reply_id: 39730[/import]

Do you want the ball to bounce off the side? What exactly are you trying to achieve? [import]uid: 23649 topic_id: 10578 reply_id: 39731[/import]

Well basically no lag, as soon as you move to one see the ball moves to the other, basically the same way as Tilt Monster… is so responsive to the tilt… [import]uid: 45615 topic_id: 10578 reply_id: 39891[/import]

Hey,

I tried your code and it worked just. I’ve never played/looked at the source code for tilt monster (yet) but I’m not sure if you knew this but the whole game is open source now.

You can find the link here: http://developer.anscamobile.com/code/tilt-monster

Hopefully that you’ll help you. [import]uid: 23649 topic_id: 10578 reply_id: 39904[/import]