移除物理引擎 移动到新库
This commit is contained in:
28
source/src/Physics/Shapes/Box.ts
Normal file
28
source/src/Physics/Shapes/Box.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
///<reference path="./Polygon.ts" />
|
||||
class Box extends Polygon {
|
||||
public width: number;
|
||||
public height: number;
|
||||
|
||||
public updateBox(width: number, height: number){
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
let halfWidth = width / 2;
|
||||
let halfHeight = height / 2;
|
||||
|
||||
this.points[0] = new Vector2(-halfWidth, -halfHeight);
|
||||
this.points[1] = new Vector2(halfWidth, -halfHeight);
|
||||
this.points[2] = new Vector2(halfWidth, halfHeight);
|
||||
this.points[3] = new Vector2(-halfWidth, halfHeight);
|
||||
|
||||
for (let i = 0; i < this.points.length; i ++)
|
||||
this._originalPoints[i] = this.points[i];
|
||||
}
|
||||
|
||||
public containsPoint(point: Vector2){
|
||||
if (this.isUnrotated)
|
||||
return this.bounds.contains(point);
|
||||
|
||||
return super.containsPoint(point);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user