Complex Body Contruction with Circles

I’m having trouble creating a complex body that includes a circle that is not centered at the origin. This may be a super simple question or not possible at all using the current implementation of Box2d in Corona. Here’s what I’ve got:

-- Create the Avatar Physics Body squareShape = { -15,-40, 15,-40, 15,45, -15,45 } sensorShape = { -8,40, 8,40, 8,50, -8,50 } physics.addBody(self.avatar, {density = .5, friction = 0, bounce = 0, shape = squareShape, filter = self.avatar\_collision\_filter }, {density = .5, friction = 0, bounce = 0, shape = sensorShape, isSensor = true, filter = self.avatar\_collision\_filter} )

I want to make my sensor a circle instead of a rectangle. I know I can specify a shape as a circle by adding a radius like this:

{density = .5, friction = 0, bounce = 0, radius = 10, isSensor = true, filter = self.avatar\_collision\_filter}  

But I can’t figure out how to move the circle from the origin. Is this possible?

Thanks. [import]uid: 136876 topic_id: 26925 reply_id: 326925[/import]

I asked about this over a year ago here
http://developer.anscamobile.com/forum/2011/04/12/multiple-circular-bodies-complex-physics-objects

Danny replied there last January saying that it would be “passed on to the team” which I think translates to “feature request buried in a hole in a secret location”.

So, no, you can’t do that right now. It seems like a simple enough tweak for Ansca to add x,y offset parameters to the body definition. Maybe nudge that thread since Danny will hopefully see it and maybe it will get some traction. [import]uid: 9422 topic_id: 26925 reply_id: 109300[/import]

While ‘.isSensor’ is a property of a display object which you have previously called ‘physics.addBody()’ on, I don’t think that it is a value which can be passed in as part of the shape definition of the body with differing values when actually calling ‘physics.addBody()’.

On the physics body doc page it says:

“A (write-only) boolean property that sets an internal “isSensor” property across all elements in the body.”

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

I would take that to mean that ‘isSensor’ needs to be set for all shapes in the physics body.

I have solved this problem in the past by creating two physics bodies, one of which is a sensor, and attaching them together with a weld joint:

http://developer.anscamobile.com/content/game-edition-physics-joints#Weld_joint [import]uid: 8271 topic_id: 26925 reply_id: 109347[/import]

Thanks for the replies. I’ll go bump the other thread.

@horacebury - I actually haven’t had any issues with using isSensor in the body definition. I don’t know if this is a recent change or a bug/feature, but that second shape is functioning as a sensor with that definition. You’re right however that I might just simplify my life by doing a weld joint in which case I won’t need to create a complex body at all. Thanks! [import]uid: 136876 topic_id: 26925 reply_id: 109358[/import]