Tilt Based Game Logic

Okay, I’ve searched as best I can these forums (searching is very broad here to say the least) and can’t find code that works.

Simple problem (not for noobs like me but…). Tilt based game based on old school wood labyrinth game.

Build settings are landscapeRight.

I found and used the code from the Shape/Tumbler demo and it works perfect, in portrait mode. Not in landscape.

[lua]local function onTilt( event )
physics.setGravity( 10 * event.xGravity, -10 * event.yGravity )
end

Runtime:addEventListener( “accelerometer”, onTilt )[/lua]

That works in portrait like the demo. I tried modifying positive and negative, changing x to y, etc… and I can get the up and down to work but still can’t get left to right working. At this point I’m out of ideas and looking for the correct code.

Thanks,
David [import]uid: 206478 topic_id: 35091 reply_id: 335091[/import]

Well found a way to make it work finally, but not sure it’s the best method. But in case anyone else is looking for ideas on this I thought I’d post it.

Just switch the x and y and apply neg 10 to both.

[lua]physics.setGravity( -10 * event.yGravity, -10 * event.xGravity )[/lua] [import]uid: 206478 topic_id: 35091 reply_id: 139824[/import]

Well found a way to make it work finally, but not sure it’s the best method. But in case anyone else is looking for ideas on this I thought I’d post it.

Just switch the x and y and apply neg 10 to both.

[lua]physics.setGravity( -10 * event.yGravity, -10 * event.xGravity )[/lua] [import]uid: 206478 topic_id: 35091 reply_id: 139824[/import]