Can physics.addBody take a group object as the first param?

I want to combine 2 display objects into one group and then add this group object into the physics engine.
e.g. I can make some balls with a number at the center of each ball with just one ball image and a text object inserted into a group.

here is my code:

local g = {}
local c = {}
local t = {}
for i=1,36,1 do
g[i] = display.newGroup()
c[i] = display.newCircle(g[i], r*2+i*2,r*2,r)
t[i] = display.newText(g[i], tostring(i), r*2+i*2,r*2, native.systemFont, 16)
c[i]:setFillColor( 255,255,255,200)
t[i]:setTextColor(255,0,0)
g[i]:insert(c[i])
g[i]:insert(t[i])
physics.addBody( g[i], ballBodyElement )
end

There is no error when I run this code.
The ball and the text are moving together, but in a strange way.

So I think the physics engine may not support a group object as one physical object.
Can you add this feature? I think it’s useful for combined images in physical world.
Thanks! [import]uid: 35642 topic_id: 7769 reply_id: 307769[/import]

+1 for this. I can see the use in a number of game situations where users combine elements that end up moving as a unit.

[import]uid: 34130 topic_id: 7769 reply_id: 28589[/import]

did you enter this as a bug report?

please do.

c. [import]uid: 24 topic_id: 7769 reply_id: 28671[/import]

In fact, following is the code that causes the wired movement.
If I comment the borders creation, the movement will be OK.
I will post this as a bug report.

local physics = require(“physics”)

local r=20

local borderBodyElement = { friction=0.5, bounce=0.8 }
local ballBodyElement = { friction=0.8, bounce=0.8, radius=r }

physics.start()

physics.setScale( 60 )
physics.setGravity( 0, 9.8 ) – initial gravity points downwards

– borders
local borderBottom = display.newRect( 0, 476, 320, 4 )
borderBottom:setFillColor( 0, 255, 0, 255) – make invisible
physics.addBody( borderBottom, “static”, borderBodyElement )

– create balls
local g = {}
local c = {}
local t = {}
for i=1,7,1 do
g[i] = display.newGroup()
c[i] = display.newCircle(g[i], i*2*r,100,r)
t[i] = display.newText(g[i], tostring(i), i*2*r,100, native.systemFont, 16)
c[i]:setFillColor( 255,255,255,200)
t[i]:setTextColor(255,0,0)
g[i]:insert(c[i])
g[i]:insert(t[i])
physics.addBody( g[i], ballBodyElement )
end
[import]uid: 35642 topic_id: 7769 reply_id: 28751[/import]