22 lines
542 B
TypeScript
Raw Normal View History

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{
//检测角色
static testAABBRole(rect:math.Rect):GRoleBase<{}>[]{
//@ts-ignore
return PhysicsSystem2D.instance.testAABB(rect).map(item => item.getComponent(GRoleBase<any>));
}
//检测角色
static testPointRole(pos:Vec2){
//@ts-ignore
console.log(PhysicsSystem2D.instance.testPoint(pos));
}
}