mirror of
https://github.com/Gongxh0901/kunpolibrary
synced 2025-06-06 09:34:21 +00:00
32 lines
858 B
TypeScript
32 lines
858 B
TypeScript
|
/**
|
||
|
* @Author: Gongxh
|
||
|
* @Date: 2024-12-21
|
||
|
* @Description: 矩形
|
||
|
*/
|
||
|
import { v2, Vec2 } from "cc";
|
||
|
import { Polygon } from "./Polygon";
|
||
|
|
||
|
// 3|2
|
||
|
// --
|
||
|
// 0|1
|
||
|
// 矩形的四个点
|
||
|
|
||
|
export class Box extends Polygon {
|
||
|
constructor(x: number, y: number, width: number, height: number, tag: number = -1) {
|
||
|
let points: Vec2[] = new Array(4);
|
||
|
points[0] = v2(x, y);
|
||
|
points[1] = v2(x + width, y);
|
||
|
points[2] = v2(x + width, y + height);
|
||
|
points[3] = v2(x, y + height);
|
||
|
super(points, tag);
|
||
|
}
|
||
|
|
||
|
public resetPoints(x: number, y: number, width: number, height: number): void {
|
||
|
let points: Vec2[] = new Array(4);
|
||
|
points[0] = v2(x, y);
|
||
|
points[1] = v2(x + width, y);
|
||
|
points[2] = v2(x + width, y + height);
|
||
|
points[3] = v2(x, y + height);
|
||
|
this.points = points;
|
||
|
}
|
||
|
}
|