Hey im having big troubles making this onCollision function work good… here is what i need and have…
local arrow = {} local aCounter = 1 local timer1 box = display.newImageRect( "box.png", 50, 50 ) box.x = display.contentCenterX box.y = display.contentCenterY physics.addBody( box, "static", { bounce = 0, radius = 25 }) box.myName = "box" box.value = 1 local function spawnArrows() arrow[aCounter] = display.newImageRect( "Black.png", 30, 60 ) arrow[aCounter].x = display.contentCenterX arrow[aCounter].y = display.contentHeight \* -0.2 arrow[aCounter].rotation = 180 physics.addBody( arrow[aCounter], "dynamic", { bounce = 0 }) arrow[aCounter].value = aCounter arrow[aCounter].myName = "arrow" arrow[aCounter].gravityScale = 0 arrow[aCounter]:setLinearVelocity( 0, 200 ) aCounter = aCounter + 1 end timer1 = timer.performWithDelay( math.random(1000,2000), spawnArrows, -1 )
so the arrows move and need to hit the box and when they do they disappear… and that would be easy but i have 4 other functions like spawnArrows… like spawnArrows2 and so on… and i cant make a correct function fo the collision…
Thanks!