local height = math.random(display.contentWidth/5\*4) local body = display.newRect(display.contentWidth/2, baseY\*5,display.contentWidth,baseY\*10) local leftShapeX = 1 local leftShape = { (-body.contentWidth/2),(body.contentHeight/2), (-body.contentWidth/2), (-body.contentHeight/2), (-body.contentWidth/2+height), (-body.contentHeight/2), (-body.contentWidth/2+height),(body.contentHeight/2) } local rightShape = { (height+display.contentWidth/5-body.x),(body.contentHeight/2), (height+display.contentWidth/5-body.x),(-body.contentHeight/2), (body.contentWidth/2),(-body.contentHeight/2), (body.contentWidth/2),(body.contentHeight/2) } local bodyMask = display.newRect(height+display.contentWidth/10,baseY\*5, display.contentWidth/5, baseY\*20) bodyMask:setFillColor(0,0,0) physics.addBody( body, { density=1.0, friction=1.0, bounce=1.0, shape = leftShape}) body:addEventListener( "collision", body )
This is full code that generate new wall with space in the middle.