I have 1000 little balls falling from the sky at a rate of 5/second that I want to change color when they pass a certain point. I can only get it to work if I launch the balls 1 every 1.2 seconds.
I think it has to do with the fact that I have more than one ball on the screen when I try to turn them red
[lua] function ballDrop()
ball = display.newCircle( 0, 0, 2)
ball:setFillColor(0, 255, 0)
ball.x = 50
ball.y = 50
ball.name = ‘ball’
physics.addBody(ball, {bounce=1.0, radius = 2,density = .1, friction=0.7})
ball:addEventListener(“collision”, ball)
function turnRed(event)
if ball.x > 0 and ball.x < 600 and ball.y > 200 and ball.y < 300 then
ball:setFillColor(200, 0, 0)
end
end
Runtime:addEventListener(“enterFrame”, turnRed)
end
tmr1 = timer.performWithDelay(200, ballDrop,1000) [/lua]
So what would be the best way to have multiple balls on the screen be able to turn red in the turnRed function? Thanks [import]uid: 75779 topic_id: 30233 reply_id: 330233[/import]