private drawDashedLine(start: cc.Vec3, end: cc.Vec3, dashLength: number = 30, color: cc.Color = cc.Color.WHITE) {
let graphics = this.graphics;
graphics.clear();
graphics.strokeColor = color;
graphics.lineWidth = 10;
let previousPos = start;
let diffX = end.x - start.x;
let diffY = end.y - start.y;
let length = Math.sqrt(diffX * diffX + diffY * diffY);
let directionX = diffX / length;
let directionY = diffY / length;
for (let i = 0; i < length; i += dashLength * 2) {
let curSegmentEndPos = cc.v3(start.x + directionX * (i + dashLength), start.y + directionY * (i + dashLength));
if (i + dashLength > length) {
curSegmentEndPos = end;
}
graphics.moveTo(previousPos.x, previousPos.y);
graphics.lineTo(curSegmentEndPos.x, curSegmentEndPos.y);
previousPos = cc.v3(start.x + directionX * (i + dashLength * 2), start.y + directionY * (i + dashLength * 2));
}
graphics.stroke();
}