Help With Programming App to work with Corona Remote

I can get the corona remote to connect to my computer and the sample programs work well. The problem is using the remote with my app. The accelerometer works when I build to an IOS device and actually test it on my physical Iphone. So, I need help with my code, I need help getting the remote variables to work with my app. Below is the code I use to run the accelerometer.

[lua]local motionx = 0
local motiony = 0

local function onAccelerate( event )
motionx = 30 * event.yGravity
motiony = 1 * event.xGravity
Runtime:addEventListener (“accelerometer”, onAccelerate)

local function moveball (event)
circle.x = circle.x - motionx
circle.y = circle.y - motiony
Runtime:addEventListener(“enterFrame”, moveball)

local function onTilt( event )
physics.setGravity( 10 * event.xGravity)
Runtime:addEventListener( “accelerometer”, onTilt )
[import]uid: 82872 topic_id: 28388 reply_id: 328388[/import]

Are you connecting to the same wifi network and host?


[import]uid: 11860 topic_id: 28388 reply_id: 114633[/import]

Yes, I downloaded some of the sample programs and the remote works. But the remote does not work with my app. [import]uid: 82872 topic_id: 28388 reply_id: 114634[/import]

– Load The Remote
local remote = require(“remote”)

– Start The Remote On Port 8080
remote.startServer( “8080” )

– Get The Latest Accelerometer Values
local function updateAccelerometer(event)

– 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


– Add Enter Frame Listener
Runtime:addEventListener( “enterFrame” , updateAccelerometer )[/lua]

Add that to the start of the file and then in your code replace event.xGravity with xGravity and event.yGravity with yGravity.

I *think* that should do it, though I haven’t played with the remote in awhile. Please let me know!

Peach :slight_smile: [import]uid: 52491 topic_id: 28388 reply_id: 114665[/import]