修复Vector2.zero引起的引用混乱问题
This commit is contained in:
@@ -110,18 +110,18 @@ module es {
|
||||
if (!this.pixelShape2.parent)
|
||||
this.debugDisplayObject.addChild(this.pixelShape2);
|
||||
|
||||
this.hollowShape.graphics.clear();
|
||||
this.hollowShape.graphics.beginFill(Colors.colliderBounds, 0);
|
||||
this.hollowShape.graphics.lineStyle(Size.lineSizeMultiplier, Colors.colliderBounds);
|
||||
this.hollowShape.graphics.drawRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
|
||||
this.hollowShape.graphics.endFill();
|
||||
// this.hollowShape.graphics.clear();
|
||||
// this.hollowShape.graphics.beginFill(Colors.colliderBounds, 0);
|
||||
// this.hollowShape.graphics.lineStyle(Size.lineSizeMultiplier, Colors.colliderBounds);
|
||||
// this.hollowShape.graphics.drawRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
|
||||
// this.hollowShape.graphics.endFill();
|
||||
|
||||
this.polygonShape.graphics.clear();
|
||||
if (poly.points.length >= 2){
|
||||
this.polygonShape.graphics.beginFill(Colors.colliderEdge, 0);
|
||||
this.polygonShape.graphics.lineStyle(Size.lineSizeMultiplier, Colors.colliderEdge);
|
||||
for (let i = 1; i < poly.points.length; i ++){
|
||||
if (i == 1){
|
||||
for (let i = 0; i < poly.points.length; i ++){
|
||||
if (i == 0){
|
||||
this.polygonShape.graphics.moveTo(poly.position.x + poly.points[i].x, poly.position.y + poly.points[i].y);
|
||||
}else{
|
||||
this.polygonShape.graphics.lineTo(poly.position.x + poly.points[i].x, poly.position.y + poly.points[i].y);
|
||||
@@ -136,6 +136,7 @@ module es {
|
||||
this.pixelShape1.graphics.beginFill(Colors.colliderPosition, 0);
|
||||
this.pixelShape1.graphics.lineStyle(4 * Size.lineSizeMultiplier, Colors.colliderPosition);
|
||||
this.pixelShape1.graphics.moveTo(this.entity.transform.position.x, this.entity.transform.position.y);
|
||||
this.pixelShape1.graphics.lineTo(this.entity.transform.position.x, this.entity.transform.position.y);
|
||||
this.pixelShape1.graphics.endFill();
|
||||
|
||||
this.pixelShape2.graphics.clear();
|
||||
@@ -143,6 +144,8 @@ module es {
|
||||
this.pixelShape2.graphics.lineStyle(2 * Size.lineSizeMultiplier, Colors.colliderCenter);
|
||||
this.pixelShape2.graphics.moveTo(this.entity.transform.position.x + this.shape.center.x,
|
||||
this.entity.transform.position.y + this.shape.center.y);
|
||||
this.pixelShape2.graphics.lineTo(this.entity.transform.position.x + this.shape.center.x,
|
||||
this.entity.transform.position.y + this.shape.center.y);
|
||||
this.pixelShape2.graphics.endFill();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
module es {
|
||||
export class CircleCollider extends Collider {
|
||||
private rectShape: egret.Shape = new egret.Shape();
|
||||
private circleShape: egret.Shape = new egret.Shape();
|
||||
private pixelShape1: egret.Shape = new egret.Shape();
|
||||
private pixelShape2: egret.Shape = new egret.Shape();
|
||||
|
||||
/**
|
||||
* 创建一个有半径的圆
|
||||
*
|
||||
@@ -41,6 +46,46 @@ module es {
|
||||
return this;
|
||||
}
|
||||
|
||||
public debugRender() {
|
||||
if (!this.rectShape.parent)
|
||||
this.debugDisplayObject.addChild(this.rectShape);
|
||||
|
||||
if (!this.circleShape.parent)
|
||||
this.debugDisplayObject.addChild(this.circleShape);
|
||||
|
||||
if (!this.pixelShape1.parent)
|
||||
this.debugDisplayObject.addChild(this.pixelShape1);
|
||||
|
||||
if (!this.pixelShape2.parent)
|
||||
this.debugDisplayObject.addChild(this.pixelShape2);
|
||||
|
||||
this.rectShape.graphics.clear();
|
||||
this.rectShape.graphics.beginFill(Colors.colliderBounds, 0);
|
||||
this.rectShape.graphics.lineStyle(Size.lineSizeMultiplier, Colors.colliderBounds);
|
||||
this.rectShape.graphics.drawRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
|
||||
this.rectShape.graphics.endFill();
|
||||
|
||||
this.circleShape.graphics.clear();
|
||||
this.circleShape.graphics.beginFill(Colors.colliderEdge, 0);
|
||||
this.circleShape.graphics.lineStyle(Size.lineSizeMultiplier, Colors.colliderEdge);
|
||||
this.circleShape.graphics.drawCircle(this.shape.position.x, this.shape.position.y, (this.shape as Circle).radius);
|
||||
this.circleShape.graphics.endFill();
|
||||
|
||||
this.pixelShape1.graphics.clear();
|
||||
this.pixelShape1.graphics.beginFill(Colors.colliderPosition, 0);
|
||||
this.pixelShape1.graphics.lineStyle(4 * Size.lineSizeMultiplier, Colors.colliderPosition);
|
||||
this.pixelShape1.graphics.moveTo(this.entity.transform.position.x, this.entity.transform.position.y);
|
||||
this.pixelShape1.graphics.lineTo(this.entity.transform.position.x, this.entity.transform.position.y);
|
||||
this.pixelShape1.graphics.endFill();
|
||||
|
||||
this.pixelShape2.graphics.clear();
|
||||
this.pixelShape2.graphics.beginFill(Colors.colliderCenter, 0);
|
||||
this.pixelShape2.graphics.lineStyle(2 * Size.lineSizeMultiplier, Colors.colliderCenter);
|
||||
this.pixelShape2.graphics.moveTo(this.shape.position.x, this.shape.position.y);
|
||||
this.pixelShape2.graphics.lineTo(this.shape.position.x, this.shape.position.y);
|
||||
this.pixelShape2.graphics.endFill();
|
||||
}
|
||||
|
||||
public toString() {
|
||||
return `[CircleCollider: bounds: ${this.bounds}, radius: ${(this.shape as Circle).radius}]`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user