2023-10-30 02:34:11 +08:00
|
|
|
import { math } from "cc";
|
|
|
|
import { PhysicsSystem2D } from "cc";
|
|
|
|
import GRoleBase from "../role/GRoleBase";
|
|
|
|
import { Vec2 } from "cc";
|
|
|
|
|
|
|
|
|
|
|
|
//检测工具类
|
|
|
|
export default class GDetection{
|
|
|
|
|
|
|
|
//检测角色
|
2023-11-30 02:20:57 +08:00
|
|
|
static testAABBCenterRole(rect:math.Rect):GRoleBase<{}>[]{
|
|
|
|
rect.x -= rect.width / 2;
|
|
|
|
rect.y -= rect.height / 2;
|
2023-10-30 02:34:11 +08:00
|
|
|
//@ts-ignore
|
2023-12-18 18:48:42 +08:00
|
|
|
return PhysicsSystem2D.instance.testAABB(rect).map(item => item.getComponent(GRoleBase<any>)).filter(role => !!role);
|
2023-10-30 02:34:11 +08:00
|
|
|
}
|
|
|
|
//检测角色
|
|
|
|
static testPointRole(pos:Vec2){
|
|
|
|
//@ts-ignore
|
|
|
|
console.log(PhysicsSystem2D.instance.testPoint(pos));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|