Thanks for the feedback/suggestions! Here is a sample of the code that I am using for my project. I am developing a word game, and am trying to combine text and rectangles (or image files) to create the letter tiles using display groups. When I place only one tile a time, no bouncing occurs, but bouncing (and other strange physics behavior) occurs when I place multiple tiles simultaneously with my createTile function, which is what I am trying to do for my app.
Thanks Brent for your suggestion about using multi-element bodies. I plan to look into this further, and it seems like it may be the best way to address my problem. I’ll post an update after I have had a chance to implement it.
local physics = require( "physics" ) physics.start() --set true to prevent all bodies from sleeping physics.setGravity( 0, 50 ) physics.setScale( 10 ) local tileWidth = 40 local ptValue = 4 local spacing = 5 local letter = "W" local rows = 4 local columns = 5 local rightX = display.contentWidth - display.screenOriginX local leftX = display.screenOriginX local function createTile( xPosition, yPosition ) local tile = display.newRect( 0, 0, tileWidth, tileWidth ) tile.x, tile.y = xPosition, yPosition tile.isFixedRotation = true tile.letter = letter tile.letterText = display.newText( letter, 0, 0, native.systemFontBold, 25 ); tile.letterText:setTextColor( 0,0,0 ) tile.letterText.x = tile.x tile.letterText.y = tile.y tile.pointValue = display.newText( tostring(ptValue), 0, 0, native.systemFontBold, 8 ) tile.pointValue:setTextColor( 0,0,0 ) tile.pointValue.x = tile.x - 12 tile.pointValue.y = tile.y - 12 local tileGroup = display.newGroup() tileGroup:insert( tile ) tileGroup:insert( tile.letterText ) tileGroup:insert( tile.pointValue ) tileGroup.anchorChildren = true tileGroup.x = xPosition tileGroup.y = yPosition physics.addBody( tileGroup, 'dynamic', { friction = 0, bounce = 0, density = 0, radius = .5\*tileWidth + .5\*spacing } ) end local groundLine = display.newRect( .5\*display.contentWidth, 300, display.contentWidth, 10 ) groundLine.anchorY = 0 groundLine:setFillColor( 1, 1, 1 ) physics.addBody( groundLine, 'static', { bounce=0, friction = 1 } ) local function generateRowOfTiles() for c = 1, columns do -- print(c) x = .5\*(rightX - leftX) - (columns\*(tileWidth + spacing ) + spacing )/2 + (c-1)\*(tileWidth + spacing ) + spacing createTile( x, 0 ) end end local timer = timer.performWithDelay( 2000, generateRowOfTiles, rows )