How do you create a sensor?

I’m trying the example on http://developer.anscamobile.com/content/game-edition-physics-bodies#Sensors

local rect = display.newRect( 50, 50, 100, 100 )
rect:setFillColor( 255, 255, 255, 100 )
rect.isVisible = false – optional
physics.newSimpleBody( rect, { isSensor = true } )

and all I get is:

Runtime error: attempt to call field ‘newSimpleBody’ (a nil value) [import]uid: 8434 topic_id: 1953 reply_id: 301953[/import]

Turns out the API has changed since Alpha 2 but the example in the documentation was missed. Ansca is going to fix it up soon. [import]uid: 8434 topic_id: 1953 reply_id: 5829[/import]

This one was my fault, but it’s corrected now:

http://developer.anscamobile.com/content/game-edition-physics-bodies#Sensors

physics.newSimpleBody() was deprecated back in Alpha 2, when the physics body constructors were all merged into physics.addBody().

Trivia: why is the function called “add” rather than “new”? Because the convention in Corona is that a “new” method returns a new object, whereas in this case we’re taking an existing display object and adding physical properties to it. [import]uid: 3007 topic_id: 1953 reply_id: 5876[/import]

The physics.addBody() change seems to have affected the way physics objects can be turned into sensors dynamically. For example in this thread (http://developer.anscamobile.com/forum/2010/09/06/one-sided-collisions) it is suggested to turn a physical object into a sensor by simply calling object.isSensor=true

That doesn’t seem to work anymore. Is this a bug or is there another way to change a physics body into a sensor on-the-fly? [import]uid: 8194 topic_id: 1953 reply_id: 6625[/import]