Accelerometer Question

I have been experimenting with the accelerometer inputs to control an object in my game. I found I could only get the accelerometer event listener to work if I also included an enterFrame listener. Can someone explain why this is? By the way I am using Cider (ultimote) to apply the accel inputs.

In the code below, the “accel” statement is only printed to the terminal if the enterFrame listener and onFrame function are uncommented.

Code:
_____________________________________________________
system.setAccelerometerInterval( 100 )
local function onTilt( event )
print(“accel”)
end

–local function onFrame()
–end

Runtime:addEventListener(“accelerometer”, onTilt)
–Runtime:addEventListener (“enterFrame”, onFrame)
_______________________________________________________

Thanks in advance,
Chris [import]uid: 146966 topic_id: 28408 reply_id: 328408[/import]

Seems to be working fine here.

Please try the following code:

[code]
io.output():setvbuf(‘no’)

system.setAccelerometerInterval( 100 )

local function onAccelerate( event )
print( event.name, event.xGravity, event.yGravity )
print( “firing” )
end

Runtime:addEventListener(“accelerometer”, onAccelerate)
[/code] [import]uid: 84637 topic_id: 28408 reply_id: 114748[/import]

Hmm, it’s the same thing when I run the code you posted.

As it is, nothing happens when I run/debug it (well the code runs, but it is not “seeing” the accelerometer input). If I add an enterFrame listener with an empty function, as soon as I run the code the terminal starts to print.

I was pretty careful to not do anything else different besides adding or removing those couple lines of code. [import]uid: 146966 topic_id: 28408 reply_id: 114866[/import]