开发者

Draw and rub(erase) the line in corona

开发者 https://www.devze.com 2023-04-12 15:38 出处:网络
I used following code to draw a line But i want to erase that line if finger touches on same line.. Any Idea?

I used following code to draw a line

But i want to erase that line if finger touches on same line.. Any Idea?

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)


Simple. Make the line a sensor and as soon as the user touches the line, remove it from the group or delete the object.

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消