I have a function that randomly spawns objects (squares) zipping across the screen from left to right, at random screen heights. I then have a draggable object (a circle) that I want to change color if struck by one of the randomly spawning squares. I don’t want there to be physics applied to these objects. Does anyone have any ideas on how to write some sort of code that detects when my circle has collided with one of the spawning squares? My square spawning code can be boiled down to something like this:
local function squareSpawn (event) timer.performWithDelay(math.random(20,35),squareSpawn) local square = display.newRect(50, 50, 100) square.x = -100 square.y = math.random(0,1024) transition.to(square, {time = 1500, delay = 0, x = square.x + 968, onComplete=function() square :removeSelf() end}) endtimer.performWithDelay(0,squareSpawn,1)[/code]And my drag function can be boiled down to something like this:local circle = display.newCircle(50, 50, 100)circle:setFillColor(255,255,255)function moveCircle( event ) circle.x = event.x circle.y = event.yendRuntime:addEventListener("touch", moveCircle)[/code]Does anyone have any knowledge on how to write a simple collision code similar to this:local sqrt = math.sqrt local dx = square.x - circle.x;local dy = square.y - circle.y; local distance = sqrt(dx*dx + dy*dy); if distance < 32 then --Collidedend[/code]but for multiple objects? Any help or suggestions would be much appreciated.Thank youSteven [import]uid: 79394 topic_id: 14186 reply_id: 314186[/import]

