移动类至es模块

This commit is contained in:
YHH
2020-07-23 09:10:27 +08:00
parent 15c0844e29
commit 814234ca61
20 changed files with 1101 additions and 998 deletions

View File

@@ -1,22 +1,26 @@
/**
* 多边形应该以顺时针方式定义
*/
class PolygonCollider extends Collider {
module es {
/**
* 如果这些点没有居中它们将以localOffset的差异为居中。
* @param points
* 多边形应该以顺时针方式定义
*/
constructor(points: Vector2[]){
super();
export class PolygonCollider extends Collider {
/**
* 如果这些点没有居中它们将以localOffset的差异为居中。
* @param points
*/
constructor(points: Vector2[]) {
super();
// 第一点和最后一点决不能相同。我们想要一个开放的多边形
let isPolygonClosed = points[0] == points[points.length - 1];
// 第一点和最后一点决不能相同。我们想要一个开放的多边形
let isPolygonClosed = points[0] == points[points.length - 1];
// 最后一个移除
if (isPolygonClosed)
points.splice(points.length - 1, 1);
// 最后一个移除
if (isPolygonClosed)
points.splice(points.length - 1, 1);
Polygon.recenterPolygonVerts(points);
this.shape = new Polygon(points);
let center = Polygon.findPolygonCenter(points);
this.setLocalOffset(center);
Polygon.recenterPolygonVerts(points);
this.shape = new Polygon(points);
}
}
}
}