The whole purpose of the game/music app.
Is to get the ball to play a sound every time it hits the “wall” or an object. But for now I just want to be able to control it.
what am I doing wrong?
___________________________________________________________
local physics = require(“physics”)
physics.start()
physics.setScale( 60 )
physics.setGravity( 0, 0 )
system.setAccelerometerInterval( 100 ) – set accelerometer to maximum responsiveness
function onTilt( event )
physics.setGravity( ( 9.8 * event.xGravity ), ( -9.8 * event.yGravity ) )
end
Runtime:addEventListener( “accelerometer”, onTilt )
display.setStatusBar( display.HiddenStatusBar )
local bkg = display.newImage( “foto.JPG” )
local soccerball = display.newImage(“soccer_ball.png”)
soccerball.x = 160; soccerball.y = 200
borderBodyElement = { friction=0.3, bounce=0.3 }
local borderTop = display.newRect( 0, 0, 320, 20 )
borderTop:setFillColor( 0, 0, 0, 0) – make invisible
physics.addBody( borderTop, “static”, borderBodyElement )
local borderBottom = display.newRect( 0, 460, 320, 20 )
borderBottom:setFillColor( 0, 0, 0, 0) – make invisible
physics.addBody( borderBottom, “static”, borderBodyElement )
local borderLeft = display.newRect( 0, 20, 20, 460 )
borderLeft:setFillColor( 0, 0, 0, 0) – make invisible
physics.addBody( borderLeft, “static”, borderBodyElement )
local borderRight = display.newRect( 300, 20, 20, 460 )
borderRight:setFillColor( 0, 0, 0, 0) – make invisible
physics.addBody( borderRight, “static”, borderBodyElement )
physics.addBody( soccerball, { density=0.9, friction=0.5, bounce=0.6, radius=38 } )
– Load The Remote
local remote = require(“remote”)
– Start The Remote On Port 8080
remote.startServer( “8080” )
– Start The Compass ( if you want to use it )
remote.startCompass()
– Get The Latest Accelerometer Values
local function updateAccelerometer()
local xGravity = remote.xGravity
local yGravity = remote.yGravity
local zGravity = remote.zGravity
local xInstant = remote.xInstant
local yInstant = remote.yInstant
local zInstant = remote.zInstant
local isShake = remote.isShake
– Only Use If Compass Activated And Running v1.1 Or Later
local magnetic = remote.magnetic
– Print xGravity To Terminal
print( remote.xGravity )
end
– Add Enter Frame Listener
Runtime:addEventListener( “enterFrame” , updateAccelerometer )
________________________________________________________________
Hope someone can help me.
Thanks.
Jimmi [import]uid: 51793 topic_id: 8756 reply_id: 308756[/import]