移除物理引擎 移动到新库
This commit is contained in:
24
source/src/ECS/Components/Physics/Colliders/BoxCollider.ts
Normal file
24
source/src/ECS/Components/Physics/Colliders/BoxCollider.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
///<reference path="./Collider.ts" />
|
||||
class BoxCollider extends Collider {
|
||||
|
||||
public get width(){
|
||||
return (this.shape as Box).width;
|
||||
}
|
||||
|
||||
public set width(value: number){
|
||||
this.setWidth(value);
|
||||
}
|
||||
|
||||
public setWidth(width: number): BoxCollider{
|
||||
this._colliderRequiresAutoSizing = false;
|
||||
let box = this.shape as Box;
|
||||
if (width != box.width){
|
||||
box.updateBox(width, box.height);
|
||||
this._isPositionDirty = true;
|
||||
if (this.entity && this._isParentEntityAddedToScene)
|
||||
Physics.updateCollider(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,16 @@ abstract class Collider extends Component{
|
||||
public shape: Shape;
|
||||
public physicsLayer = 1 << 0;
|
||||
public isTrigger: boolean;
|
||||
public registeredPhysicsBounds: Rectangle;
|
||||
|
||||
protected _isParentEntityAddedToScene;
|
||||
protected _isPositionDirty = true;
|
||||
protected _colliderRequiresAutoSizing;
|
||||
|
||||
public get bounds(): Rectangle {
|
||||
return this.shape.bounds;
|
||||
}
|
||||
|
||||
public initialize() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user