I’m playing with physics in corona and cant make my “ball”'s collide with each other and print something because of it
it will be easy other way, but balls spawning randomly and i can align only one name on it,i think…
anyway when pad bounce the ball back i need that ball to bounce with another ball and remove self and the ball it touches
so, any help is appreciated
[lua]local physics = require(“physics”)
physics.start()
physics.setGravity(0,1)
function removeball(event)
if event.other.name == “ball” then
b:removeSelf()
end
end
function newBall()
rand = math.random
if(rand(1,100)) then
b = display.newCircle(0,0,20)
b:setFillColor(255,0,0)
b.x = 60 + rand(320)
b.y = - 100
physics.addBody(b, “dynamic”,{density=1,friction=1,bounce=1,radius=20})
b.myName = “ball”
b:addEventListener(“collision”, removeball)
end
end
local dropBalls = timer.performWithDelay( 500, newBall, 100 )
local pad = display.newRect(0,0,70,15)
pad.x = display.contentWidth/2; pad.y = 300
pad.myName = “pad”
physics.addBody(pad,“static”)
local function move_bad(event)
pad.x = event.x
end
pad:addEventListener(“touch”, move_bad)
local function onCollisionEvent(event)
if event.other.myName == “ball” then
print(“ball touched”)
end
end
pad:addEventListener(“collision”, onCollisionEvent)[/lua] [import]uid: 16142 topic_id: 12443 reply_id: 312443[/import]
[import]uid: 52491 topic_id: 12443 reply_id: 45425[/import]