修复polygon数组错误 修复emit空注册报错

This commit is contained in:
yhh
2020-06-15 20:08:21 +08:00
parent c3120d791f
commit 5186bc0187
16 changed files with 398 additions and 32 deletions

View File

@@ -22,7 +22,7 @@ class Polygon extends Shape {
private buildEdgeNormals(){
let totalEdges = this.isBox ? 2 : this.points.length;
if (this._edgeNormals == null || this._edgeNormals.length != totalEdges)
this._edgeNormals = new Vector2[totalEdges];
this._edgeNormals = new Array(totalEdges);
let p2: Vector2;
for (let i = 0; i < totalEdges; i ++){
@@ -42,7 +42,7 @@ class Polygon extends Shape {
this.points = points;
this.recalculateCenterAndEdgeNormals();
this._originalPoints = new Vector2[points.length];
this._originalPoints = new Array(points.length);
this._originalPoints = points;
}
@@ -116,7 +116,7 @@ class Polygon extends Shape {
}
public static buildSymmertricalPolygon(vertCount: number, radius: number) {
let verts = new Vector2[vertCount];
let verts = new Array(vertCount);
for (let i = 0; i < vertCount; i++) {
let a = 2 * Math.PI * (i / vertCount);
@@ -125,4 +125,8 @@ class Polygon extends Shape {
return verts;
}
public recalculateBounds(collider: Collider) {
this.center = collider.localOffset;
}
}