Downloadable example (written w/ SSK but you can convert to regular Corona): http://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/11/bouncy.zip
Solution in action:
https://www.youtube.com/watch?v=H2WXQUP6pL4&feature=youtu.be
Example coded with SSK (pay attention to the physics settings I used (second table in makers)):
-- -- Interesting bits start after this... -- local physics = require "physics" physics.start() physics.setGravity(0,0) local ballSpeed = 500 -- 100 pixels per second -- Walls local lw = newRect( nil, left, centerY, { fill = \_B\_, w = 40, h = fullh, anchorX = 0 }, { bodyType = "static", bounce = 1, friction = 0 } ) local rw = newRect( nil, right, centerY, { fill = \_B\_, w = 40, h = fullh, anchorX = 1 }, { bodyType = "static", bounce = 1, friction = 0 } ) local tw = newRect( nil, centerX, top, { fill = \_B\_, w = fullw, h = 40, anchorY = 0 }, { bodyType = "static", bounce = 1, friction = 0 } ) local bw = newRect( nil, centerX, bottom, { fill = \_B\_, w = fullw, h = 40, anchorY = 1 }, { bodyType = "static", bounce = 1, friction = 0 } ) local enterFrame = function( self ) local vx,vy = self:getLinearVelocity() vx,vy = normVec( vx, vy ) vx,vy = scaleVec( vx, vy, ballSpeed ) self:setLinearVelocity( vx, vy ) end local function newBall( x, y, angle ) local ball = newCircle( nil, x, y, { radius = 25, fill = randomColor(), stroke = randomColor(), strokeWidth = 2 }, { bounce = 1, friction = 0, isFixedRotation = true } ) local vec = angle2Vector( angle, true ) vec = scaleVec( vec, ballSpeed ) ball:setLinearVelocity( vec.x, vec.y ) ball.enterFrame = enterFrame listen( "enterFrame", ball ) end for i = 1, 25 do timer.performWithDelay( (i-1) \* 500, function() newBall( centerX, centerY, mRand(0,359) ) end ) end