So I took the shapetumbler example and trimmed it down to one circular object that’s supposed to be a pinball. I then want to use the device’s accelerometer to control the ball. I build 4 static walls to stop the ball from leaving the screen. This seems to work OK except that when the ball comes to rest in a corner it stops responding to the gravity events. (Tested on an iPad mini retina)
local \_W = display.contentWidth local \_H = display.contentHeight local physics = require("physics") physics.setDrawMode("debug") physics.start() physics.setScale( 60 ) physics.setGravity( 0, 0 ) system.setAccelerometerInterval( 100 ) -- set accelerometer to maximum responsiveness display.setStatusBar( display.HiddenStatusBar ) function onTilt( event ) physics.setGravity( ( 9.82 \* event.xGravity ), ( -9.82 \* event.yGravity ) ) end Runtime:addEventListener( "accelerometer", onTilt ) borderBodyElement = { friction= 0.3, bounce = .5 } local borderTop = display.newRect( 0, 0, \_W,30 ) borderTop.anchorX = 0 physics.addBody( borderTop, "static", borderBodyElement ) local borderBottom = display.newRect( 0, \_H , \_W, 30) borderBottom.anchorX = 0 physics.addBody( borderBottom, "static", borderBodyElement ) local borderLeft = display.newRect( 0, 0, 30, \_H ) borderLeft.anchorY = 0 physics.addBody( borderLeft, "static", borderBodyElement ) local borderRight = display.newRect( \_W , 0, 30, \_H ) borderRight.anchorY = 0 physics.addBody( borderRight, "static", borderBodyElement ) local ball = display.newImage("super\_ball.png", 80, 160 ) physics.addBody( ball, { radius=24 } )