public static hitTest(obj1: egret.DisplayObject,obj2: egret.DisplayObject): boolean {
var rect1:egret.Rectangle = obj1.getBounds();//获取显示对象的测量边界
var rect2:egret.Rectangle = obj2.getBounds();
rect1.x = obj1.x;
rect1.y = obj1.y;
rect2.x = obj2.x;
rect2.y = obj2.y;
//确定在 toIntersect 参数中指定的对象是否与此 Rectangle 对象相交。
//此方法检查指定的 Rectangle对象的 x、y、width 和 height 属性,以查看它是否与此 Rectangle 对象相交
return rect1.intersects(rect2);
}
Egret碰撞检测
猜你喜欢
转载自blog.csdn.net/shenysun/article/details/82590776
今日推荐
周排行