Can't get Corona Remote to work. Newbie

2 replies [Last post]
jimmirbn
User offline. Last seen 1 year 18 weeks ago. Offline
Joined: 10 Apr 2011

Hi Guys.
new to Corona.
Loving it so far. ;)
though still have some problems getting the Remote to work.
I get the connection but nothing happens.

The idea is to control the soccer ball. like "floating"

___________________________________________________________

local physics = require("physics")
physics.start()
physics.setScale( 60 )
physics.setGravity( 0, 9.8)

-- Load The Remote
local remote = require("remote")

-- Start The Remote On Port 8080
remote.startServer( "8080" )

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 )

function updateAccelerometer()

-- This Runtime Listener Is An Example Of How To
-- Access The Remote You Can Query remote.xGravity
-- Or Any Other Value From Anywhere In Your Application

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

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( 200, 0, 0, 255) -- make invisible
physics.addBody( borderTop, "static", borderBodyElement )

local borderBottom = display.newRect( 0, 460, 720, 20 )
borderBottom:setFillColor( 200, 40, 10, 255) -- make invisible
physics.addBody( borderBottom, "static", borderBodyElement )

local borderLeft = display.newRect( 0, 20, 20, 460 )
borderLeft:setFillColor( 200, 40, 10, 255) -- make invisible
physics.addBody( borderLeft, "static", borderBodyElement )

local borderRight = display.newRect( 300, 20, 20, 460 )
borderRight:setFillColor( 200, 0, 0, 255) -- make invisible
physics.addBody( borderRight, "static", borderBodyElement )

physics.addBody( soccerball, { density=0.9, friction=0.5, bounce=0.0, radius=38 } )

_____________________________________________________________________

Hope you can help.

Thanks.
Jimmi

Replies

Big Z Labs
User offline. Last seen 5 weeks 5 days ago. Offline
Joined: 17 Jan 2011

Just change the portion of your code to this (Make sure you have the remote.lua file in your folder). - Chris

-- Load The Remote
local remote = require("remote")

-- Start The Remote On Port 8080
remote.startServer( "8080" )

system.setAccelerometerInterval( 100 ) -- set accelerometer to maximum responsiveness

function onTilt( event )
local xGravity = remote.xGravity
local yGravity = remote.yGravity

physics.setGravity( ( 9.8 * xGravity ), ( -9.8 * yGravity ) )
end

Runtime:addEventListener( "enterFrame" , onTilt)

display.setStatusBar( display.HiddenStatusBar )

local bkg = display.newImage( "foto.JPG" )
local soccerball = display.newImage("soccer_ball.png")
soccerball.x = 160; soccerball.y = 200
...

Matthew Pringle
User offline. Last seen 32 weeks 6 days ago. Offline
Joined: 23 Feb 2010

If you are still having trouble email me at support@coronaremote.com and I will have a look

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.