Runtime Event Removal

So, I’m using the function below to return some tilt info. I am also removing the listener when I exit the scene using this - Runtime:removeEventListener( "accelerometer", onTilt ).

However I notice that while viewing the Xcode console, the accelerometer events keep firing after I change scenes. Apparently NOT unloading the event listener. Any thoughts as to how I can remove that so as to not eat up memory and battery? What am I doing wrong? Thanks.

Brian

local function onTilt( event ) motionx = (30 \* event.yGravity) print(motionx) if motionx \> 0 then transition.to( homeSign, { time=300, rotation=3 }) else transition.to( homeSign, { time=300, rotation=-3 }) end end Runtime:addEventListener( "accelerometer", onTilt ) [import]uid: 141982 topic_id: 37285 reply_id: 67285[/import]

Check out this thread:

https://developer.coronalabs.com/forum/2013/02/11/runtimeremoveeventlistener-messes-game [import]uid: 135394 topic_id: 37285 reply_id: 145537[/import]

Perfect! Thanks! [import]uid: 141982 topic_id: 37285 reply_id: 145541[/import]

quick question. How did you get the xcode console? [import]uid: 130035 topic_id: 37285 reply_id: 145584[/import]

Open Xcode and plug your iPad in to your computer. When you do that, your iPad will appear on the left side of the Organizer window (click on Window/Organizer in Xcode to view that window).

Once in the Organizer, find your iPad and then click on “console” in the left hand pane.

While viewing the console, you can see all kinds of cool stuff…your print output and lots of other goodies.

Hope that helps.

Brian [import]uid: 141982 topic_id: 37285 reply_id: 145588[/import]

Check out this thread:

https://developer.coronalabs.com/forum/2013/02/11/runtimeremoveeventlistener-messes-game [import]uid: 135394 topic_id: 37285 reply_id: 145537[/import]

Perfect! Thanks! [import]uid: 141982 topic_id: 37285 reply_id: 145541[/import]

quick question. How did you get the xcode console? [import]uid: 130035 topic_id: 37285 reply_id: 145584[/import]

Open Xcode and plug your iPad in to your computer. When you do that, your iPad will appear on the left side of the Organizer window (click on Window/Organizer in Xcode to view that window).

Once in the Organizer, find your iPad and then click on “console” in the left hand pane.

While viewing the console, you can see all kinds of cool stuff…your print output and lots of other goodies.

Hope that helps.

Brian [import]uid: 141982 topic_id: 37285 reply_id: 145588[/import]