我使用以下代码绘制一条线
但是如果手指碰到同一条线,我想要删除那条线。任何想法?
function drawLine( event )
if(event.phase == "ended") then
line = display.newLine(event.xStart, event.yStart, event.x, event.y)
line:setColor(255,0,0)
line.width = 5
end
end
Runtime:addEventListener("touch", drawLine)
答案 0 :(得分:0)
简单。将线条设为传感器,一旦用户触摸线条,将其从组中移除或删除对象。
physics.addBody( line, { isSensor = true } )
someGroup:insert(line)
line.collision = removeLine --some function that removes the line from the group someGroup
line:addEventListener(""touch"", line)