Hello,
Is not detecting the collision between the “line” that is rising and the “paredeALinha”.
I want to erase the line when they clash, but it is not working.
does anyone know why?
full code on github
https://github.com/Filipeasr/CoronaGame
--... --colisoes.lua --... function onCollisionParedeCimaLinha( event ) if ( event.phase == "began" ) then if (event.object2.myName == "linha")then if (event.object1.myName == "paredeALinha" ) then event.object2:removeSelf() print "onCollisionParedeCimaLinha" end end end end --... --scene2.lua --... lines = {} local prev\_x local prev\_y line\_number = 1 local line\_width = 5 function drawLine (e) local group = self.view if e.phase == "began" then prev\_x = e.x prev\_y = e.y elseif e.phase == "moved" then lines[line\_number] = display.newLine(group,prev\_x, prev\_y, e.x, e.y) lines[line\_number].alpha = .5 lines[line\_number].strokeWidth = line\_width dist\_x = e.x - prev\_x dist\_y = e.y - prev\_y fisica.addBody(lines[line\_number], "static", { density = 3, friction = 0, bounce = 0, shape = {0, 0, dist\_x, dist\_y, 0, 0} } ) prev\_x = e.x prev\_y = e.y line\_number = line\_number + 1 lines.isSensor = false lines.myName = "linha" print(lines.myName) elseif e.phase == "ended" then print "drawLine" for i=1, line\_number do transition.to( lines[i], {time=4100000, y = -500000} ) end end return lines[line\_number] end Runtime:addEventListener( "collision", onCollisionParedeCimaLinha) --... --paredes.lua --... paredeALinha = display.newRect(0, -10, 700, 10) fisica.addBody(paredeALinha, "kinematic") paredeALinha.isFixedRotation=true paredeALinha.myName = "paredeALinha" paredeALinha.isVisible = false