坡度碰撞检测修改

This commit is contained in:
joylink_zhaoerwei 2023-08-08 15:07:13 +08:00
parent b365fc4dc7
commit ddb03f379d
2 changed files with 8 additions and 8 deletions

View File

@ -30,6 +30,7 @@ export class Slope extends JlGraphic {
lineGraphic: Graphics; lineGraphic: Graphics;
slopeNumber: VectorText; slopeNumber: VectorText;
slopeLong: VectorText; slopeLong: VectorText;
changePoints: IPointData[] = [];
constructor() { constructor() {
super(Slope.Type); super(Slope.Type);
this.lineGraphic = new Graphics(); this.lineGraphic = new Graphics();
@ -69,8 +70,10 @@ export class Slope extends JlGraphic {
this.datas.points.forEach((p, i) => { this.datas.points.forEach((p, i) => {
if (i !== 0) { if (i !== 0) {
this.lineGraphic.lineTo(p.x, p.y + distanceY); this.lineGraphic.lineTo(p.x, p.y + distanceY);
this.changePoints.push({ x: p.x, y: p.y + distanceY });
} else { } else {
this.lineGraphic.moveTo(p.x, p.y - distanceY); this.lineGraphic.moveTo(p.x, p.y - distanceY);
this.changePoints.push({ x: p.x, y: p.y - distanceY });
} }
}); });
//坡度值 //坡度值

View File

@ -110,14 +110,11 @@ class SlopeGraphicHitArea implements IHitArea {
this.slope = slope; this.slope = slope;
} }
contains(x: number, y: number): boolean { contains(x: number, y: number): boolean {
for (let i = 1; i < this.slope.datas.points.length; i++) { let contains = false;
const p1 = this.slope.datas.points[i - 1]; const p1 = this.slope.changePoints[0];
const p2 = this.slope.datas.points[i]; const p2 = this.slope.changePoints[1];
if (linePoint(p1, p2, { x, y }, SlopeConsts.lineWidth)) { contains = contains || linePoint(p1, p2, { x, y }, SlopeConsts.lineWidth);
return true; return contains;
}
}
return false;
} }
} }