2025-02-20 11:27:28 +08:00
|
|
|
/**
|
|
|
|
* @Author: Gongxh
|
|
|
|
* @Date: 2024-12-21
|
|
|
|
* @Description: 原型
|
|
|
|
*/
|
|
|
|
|
2025-05-26 17:27:59 +08:00
|
|
|
import { Rect } from "cc";
|
2025-05-27 18:19:41 +08:00
|
|
|
import { ShapeType } from "./IShape";
|
2025-02-20 11:27:28 +08:00
|
|
|
import { Shape } from "./Shape";
|
|
|
|
|
|
|
|
export class Circle extends Shape {
|
2025-05-28 11:19:40 +08:00
|
|
|
private _radius: number; // 半径
|
2025-05-27 18:19:41 +08:00
|
|
|
|
|
|
|
public get shapeType(): ShapeType {
|
|
|
|
return ShapeType.CIRCLE;
|
|
|
|
}
|
|
|
|
|
2025-02-20 11:27:28 +08:00
|
|
|
constructor(radius: number, tag: number = -1) {
|
|
|
|
super(tag);
|
2025-05-28 11:19:40 +08:00
|
|
|
this._radius = radius;
|
|
|
|
this._boundingBox.x = -this._radius;
|
|
|
|
this._boundingBox.y = -this._radius;
|
|
|
|
this._boundingBox.width = this._radius * 2;
|
|
|
|
this._boundingBox.height = this._radius * 2;
|
2025-02-20 11:27:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public getBoundingBox(): Rect {
|
2025-05-27 18:19:41 +08:00
|
|
|
return this._boundingBox;
|
2025-02-20 11:27:28 +08:00
|
|
|
}
|
2025-05-28 11:19:40 +08:00
|
|
|
|
|
|
|
public get radius(): number {
|
|
|
|
return this._radius;
|
|
|
|
}
|
|
|
|
|
|
|
|
public set radius(value: number) {
|
|
|
|
this._radius = value;
|
|
|
|
this._boundingBox.x = -this._radius;
|
|
|
|
this._boundingBox.y = -this._radius;
|
|
|
|
this._boundingBox.width = this._radius * 2;
|
|
|
|
this._boundingBox.height = this._radius * 2;
|
|
|
|
}
|
2025-02-20 11:27:28 +08:00
|
|
|
}
|