Maybe not possible? Groups/Physics & Text Disappearing on Contact....

So I think I remember reading that when you’re applying physcis to objects, they all need to reside in the same display group, so that could very well be my problem–since I am inserting objects into a display group, and then inserting those groups into my main display group, and then applying the phyics paramters to each group. BUT, that does seem to work. The only odd thing I’m seeing is that when two objects collides (two of the circles in the below code), the text disappears, as if it’s been knocked away somewhere. Anyone have any idea what’s wrong, or if I’m just doing this all wrong to begin with?

Thanks,
Scott.

[lua] local localGroup = display.newGroup()
local popCircles = {};

local background = display.newImageRect(“bg-lateevening.png”,768,1024)
background:setReferencePoint(display.TopLeftReferencePoint)
background.x = 0
background.y = 0
localGroup:insert(background)

local borderBottom = display.newRect(localGroup, 0, 900, 768, 4 )
borderBottom:setFillColor( 255,255,255) – make invisible
borderBodyElement = { friction=0.4, bounce=0.8 }

physics.addBody( borderBottom, “static”, borderBodyElement )
–loop over circles.
for i=1,2 do
local group = display.newGroup()
local redBody = { density=0.2, friction=0, bounce=0.95, radius=50.0}

popCircles[i] = display.newCircle( 0, 0, 50 )
popCircles[i]:setFillColor(255,255,255)
popCircles[i].id = i
popCircles[i]:setReferencePoint(display.CenterReferencePoint)

group:insert(popCircles[i])

local label = display.newText(group,i,0,0,native.systemFontBold,24)
label:setTextColor(0,0,0)
label.x = popCircles[i].x
label.y = popCircles[i].y
label:toFront();
–group:addEventListener(“touch”,rectTouchListener)

group:setReferencePoint(display.CenterReferencePoint)
group.x = math.random(0,300) ;
group.y = math.random(0,1024) ;

physics.addBody( group, redBody )

localGroup:insert(group)

end[/lua] [import]uid: 19193 topic_id: 18248 reply_id: 318248[/import]

local physics = require( “physics” )
physics.start()
Try adding this before you begin adding bodies. [import]uid: 64112 topic_id: 18248 reply_id: 69839[/import]

Sorry, it wasn’t a full cut and paste, that part is in there, and the physics part works…it’s the text disappearing on collision that is confusing me.
[import]uid: 19193 topic_id: 18248 reply_id: 69841[/import]

:slight_smile: That will happen.
What does it tell you when your run it with the debugger?
I have ran physics in a group that’s been inserted into the main group, so I know that will work. [import]uid: 64112 topic_id: 18248 reply_id: 69844[/import]

I wasn’t getting any errors, but I seem to have fixed it by turning off rotation for the group:
group.isFixedRotation = true

I guess, in theory, that it was rotating to the backside of the group… or that newText couldn’t deal with trying to rotate itself.

Either way, that seems to fix it. [import]uid: 19193 topic_id: 18248 reply_id: 69845[/import]