I did it just for fun, but i think this is something what you need, just edit it for your own purposes
[lua]_W = display.contentWidth
_H = display.contentHeight
local physics = require(“physics”)
physics.start()
local top = display.newRect(10,0,_W,10)
physics.addBody(top, “static”)
top.name = “top”
local left = display.newRect(0,0,10, _H)
physics.addBody(left, “static”)
left.name = “left”
local bottom = display.newRect(0,_H-10,_W, 10)
physics.addBody(bottom, “static”)
bottom.name = “bottom”
local right = display.newRect(_W-10,0, 10, _H)
physics.addBody(right, “static”)
right.name = “right”
local ball1 = display.newCircle(_W/2+50, _H/2, 30)
ball1.name = “ball1”
local ball2 = display.newCircle(_W/2-50, _H/2, 30)
ball2.name = “ball2”
local function onAccelerate( event )
if event.isShake == true then
physics.addBody(ball1, {friction=0.1, bounce =0.5, radius = 30})
ball1:applyLinearImpulse(10,10, ball1.x, ball1.y)
physics.addBody(ball2, {friction=0.1, bounce =0.5, radius = 30})
ball2:applyLinearImpulse(-10,-10, ball2.x, ball2.y)
end
end
Runtime:addEventListener (“accelerometer”, onAccelerate)
local function onCollision(event)
if event.other.name == “top” or event.other.name == “bottom” or event.other.name == “left” or event.other.name == “right” then
event.target:setFillColor(math.random(1,255),math.random(1,255), math.random(1,255))
end
end
ball1:addEventListener(“collision”, onCollision)
ball2:addEventListener(“collision”, onCollision)[/lua] [import]uid: 16142 topic_id: 14007 reply_id: 51581[/import]