出现问题图片
问题描述
那几个分离的点是先画上去的, 在后来划线时,会莫名其妙把它们连起来,生成很奇怪的图片。每次touchEnd和touchCancel都清空路径上的点的,很不解为啥会出现这个问题。下面贴上代码。(是参考之前UU的直播写的)
onTouchStart (event) {
let graphics = this.graphics
let pos = this.node.convertToNodeSpaceAR(event.getLocation())
this.path.push(pos)
graphics.moveTo(pos.x, pos.y)
}
onTouchMove (event) {
let graphics = this.graphics
let pos = this.node.convertToNodeSpaceAR(event.getLocation())
this.path.push(pos)
let len = this.path.length
let p1 = this.path[0]
let p2 = this.path[1]
graphics.moveTo(p1.x, p1.y)
for (let i = 1; i < len; i++) {
let pMid = p1.add(p2).mul(0.5)
graphics.quadraticCurveTo(p1.x, p1.y, pMid.x, pMid.y)
p1 = this.path[i]
p2 = this.path[i+1]
}
graphics.stroke()
}
onTouchEnd (event) {
this.path = []
}
onTouchCancel(event) {
this.path = []
}
P.S. v1.9.3上试过是没有这个问题的。