Bouncing Balls

Hello, kinda new to lua so go easy on me here. I’m taking what i learned from the Frame animation sample and trying to edit it to create a screen where all the balls collide with each other and the wall. There should be no friction as i want them to be rebounding against the wall and the other balls. From editing the sample code i get really iffy results of balls returning to the floor and no independent moving. IF friction is "0’ shouldn’t the balls keep rebounding?

[code]
local physics = require(“physics”)
physics.start()
physics.setScale( 60 )

display.setStatusBar( display.HiddenStatusBar )

local bkg = display.newImage( “clouds.png” )

borderCollisionFilter = { categoryBits = 1, maskBits = 6 } – collides with (4 & 2) only
borderBodyElement = { friction=0, bounce=.5, filter=borderCollisionFilter }

local borderTop = display.newRect( 0, 0, 320, 1 )
borderTop:setFillColor( 0, 0, 0, 0) – make invisible
physics.addBody( borderTop, “static”, borderBodyElement )

local borderBottom = display.newRect( 0, 479, 320, 1 )
borderBottom:setFillColor( 0, 0, 0, 0) – make invisible
physics.addBody( borderBottom, “static”, borderBodyElement )

local borderLeft = display.newRect( 0, 1, 1, 480 )
borderLeft:setFillColor( 0, 0, 0, 0) – make invisible
physics.addBody( borderLeft, “static”, borderBodyElement )

local borderRight = display.newRect( 319, 1, 1, 480 )
borderRight:setFillColor( 0, 0, 0, 0) – make invisible
physics.addBody( borderRight, “static”, borderBodyElement )
local red = {}
local redCollisionFilter = { categoryBits = 2, maskBits = 3 } – collides with (2 & 1) only
local redBody = { density=0.4, friction=0, bounce=0.8, radius=43.0, filter=redCollisionFilter }

for i = 1,4 do
red[i] = display.newImage( “red.png”, (80*i)-60, 50 + math.random(20) )
physics.addBody( red[i], redBody )
red[i].isFixedRotation = true

end
[/code] [import]uid: 20195 topic_id: 5502 reply_id: 305502[/import]