移除Core,新增各接口用于sdk扩展
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
module es {
|
||||
export class CircleCollider extends Collider {
|
||||
/**
|
||||
* 创建一个有半径的圆
|
||||
* 创建一个具有半径的CircleCollider。
|
||||
* 请注意,当指定半径时,如果在实体上使用RenderableComponent,您将需要设置原点来对齐CircleCollider。
|
||||
* 例如,如果RenderableComponent有一个0,0的原点,并且创建了一个半径为1.5f * renderable.width的CircleCollider,你可以通过设置originNormalied为中心除以缩放尺寸来偏移原点
|
||||
*
|
||||
* @param radius
|
||||
*/
|
||||
@@ -24,18 +26,27 @@ module es {
|
||||
* @param radius
|
||||
*/
|
||||
public setRadius(radius: number): CircleCollider {
|
||||
this._colliderRequiresAutoSizing = false;
|
||||
let circle = this.shape as Circle;
|
||||
if (radius != circle.radius) {
|
||||
circle.radius = radius;
|
||||
circle._originalRadius = radius;
|
||||
this._isPositionDirty = true;
|
||||
|
||||
if (this.entity && this._isParentEntityAddedToScene)
|
||||
if (this.entity != null && this._isParentEntityAddedToScene)
|
||||
Physics.updateCollider(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public debugRender(batcher: IBatcher) {
|
||||
batcher.drawHollowRect(this.bounds, Debug.colliderBounds, 1);
|
||||
batcher.drawCircle(this.shape.position, (this.shape as Circle).radius, Debug.colliderEdge, 1);
|
||||
batcher.drawPixel(this.entity.transform.position, Debug.colliderPosition, 4);
|
||||
batcher.drawPixel(this.shape.position, Debug.colliderCenter, 2);
|
||||
}
|
||||
|
||||
public toString() {
|
||||
return `[CircleCollider: bounds: ${this.bounds}, radius: ${(this.shape as Circle).radius}]`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user