roll around marble game using corona?

Will corona expose the orientation of an iphone / android phone enough to make a roll around marble game (where you dodge the holes and move the marble by tilting the device one way or another. 

I see iphone games out there that do similar things but don’t see the level / tilt data in the API. I assume it does not use the acceleratormeters, but I could be mistaken.

Thanks!

No problem. Corona can do this. Mind you, because there is no 3D in Corona it is not evident to get a realistic rolling ball effect - but this is definitely NOT necessary to make a cool rolling marble game (look at Dark Nebula).

How do you get the level or tilt of a device from Corona?

I remember there was 6 directions (laid left / right, right side up, upside down, and that sort of thing for orientation) but it would not let you  get degrees of rotation or tilt of device.

Thanks!
stu

This is the code from my first game Omniblaster where you used tilt to move the ship side to side.  Same basic idea you’re wanting to do:

local function onTilt(event) app.myRocket.x = (app.myRocket.x + event.xGravity \* ((app.sensitivity \* 15 )+ level)) &nbsp;&nbsp;&nbsp; if app.myRocket.x \< 0 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; app.myRocket.x = 0 &nbsp;&nbsp;&nbsp; elseif app.myRocket.x \> (display.contentWidth - 64) then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; app.myRocket.x = display.contentWidth - 64 &nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp; return true end Runtime:addEventListener("accelerometer", onTilt )

No need to mess with orientation events, just use the accelerometer to get your X, Y and Z movement.

Rob

Try something like this to get you started. 

 local centerX = display.contentCenterX local centerY = display.contentCenterY local \_W = display.contentWidth local \_H = display.contentHeight local physics = require("physics") physics.setDrawMode("hybrid") 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( ( -7 \* event.yGravity ), ( -7 \* event.xGravity ) ) end Runtime:addEventListener( "accelerometer", onTilt ) local borderBodyElement = { friction= 0.3, bounce = .5 } local borderTop = display.newRect( 0, 0, \_W,30 ) borderTop.anchorX = 0 borderTop:setFillColor( 0, 0, 0, 0) physics.addBody( borderTop, "static", borderBodyElement ) local borderBottom = display.newRect( 0, \_H , \_W, 30) borderBottom.anchorX = 0 borderBottom:setFillColor( 0, 0, 0, 0) physics.addBody( borderBottom, "static", borderBodyElement ) local borderLeft = display.newRect( 0, 0, 30, \_H ) borderLeft.anchorY = 0 borderLeft:setFillColor( 0, 0, 0, 0) physics.addBody( borderLeft, "static", borderBodyElement ) local borderRight = display.newRect( \_W , 0, 30, \_H ) borderRight.anchorY = 0 borderRight:setFillColor( 0, 0, 0, 0) physics.addBody( borderRight, "static", borderBodyElement ) local ball = display.newImage("Icon-60.png", 60, 60 ) physics.addBody( ball, { radius = 30 } ) ball.isSleepingAllowed = false ball.x = \_W / 2 ball.y = \_H / 2

No problem. Corona can do this. Mind you, because there is no 3D in Corona it is not evident to get a realistic rolling ball effect - but this is definitely NOT necessary to make a cool rolling marble game (look at Dark Nebula).

How do you get the level or tilt of a device from Corona?

I remember there was 6 directions (laid left / right, right side up, upside down, and that sort of thing for orientation) but it would not let you  get degrees of rotation or tilt of device.

Thanks!
stu

This is the code from my first game Omniblaster where you used tilt to move the ship side to side.  Same basic idea you’re wanting to do:

local function onTilt(event) app.myRocket.x = (app.myRocket.x + event.xGravity \* ((app.sensitivity \* 15 )+ level)) &nbsp;&nbsp;&nbsp; if app.myRocket.x \< 0 then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; app.myRocket.x = 0 &nbsp;&nbsp;&nbsp; elseif app.myRocket.x \> (display.contentWidth - 64) then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; app.myRocket.x = display.contentWidth - 64 &nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp; return true end Runtime:addEventListener("accelerometer", onTilt )

No need to mess with orientation events, just use the accelerometer to get your X, Y and Z movement.

Rob

Try something like this to get you started. 

 local centerX = display.contentCenterX local centerY = display.contentCenterY local \_W = display.contentWidth local \_H = display.contentHeight local physics = require("physics") physics.setDrawMode("hybrid") 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( ( -7 \* event.yGravity ), ( -7 \* event.xGravity ) ) end Runtime:addEventListener( "accelerometer", onTilt ) local borderBodyElement = { friction= 0.3, bounce = .5 } local borderTop = display.newRect( 0, 0, \_W,30 ) borderTop.anchorX = 0 borderTop:setFillColor( 0, 0, 0, 0) physics.addBody( borderTop, "static", borderBodyElement ) local borderBottom = display.newRect( 0, \_H , \_W, 30) borderBottom.anchorX = 0 borderBottom:setFillColor( 0, 0, 0, 0) physics.addBody( borderBottom, "static", borderBodyElement ) local borderLeft = display.newRect( 0, 0, 30, \_H ) borderLeft.anchorY = 0 borderLeft:setFillColor( 0, 0, 0, 0) physics.addBody( borderLeft, "static", borderBodyElement ) local borderRight = display.newRect( \_W , 0, 30, \_H ) borderRight.anchorY = 0 borderRight:setFillColor( 0, 0, 0, 0) physics.addBody( borderRight, "static", borderBodyElement ) local ball = display.newImage("Icon-60.png", 60, 60 ) physics.addBody( ball, { radius = 30 } ) ball.isSleepingAllowed = false ball.x = \_W / 2 ball.y = \_H / 2