修复boxcollider碰撞问题

This commit is contained in:
yhh
2020-07-09 14:16:10 +08:00
parent aea50926a9
commit 6e3eb1189a
22 changed files with 241 additions and 177 deletions

View File

@@ -10,7 +10,7 @@ class Flags {
* @param self
* @param flag
*/
public static isFlagSet(self: number, flag: number){
public static isFlagSet(self: number, flag: number): boolean{
return (self & flag) != 0;
}
@@ -19,7 +19,7 @@ class Flags {
* @param self
* @param flag
*/
public static isUnshiftedFlagSet(self: number, flag: number){
public static isUnshiftedFlagSet(self: number, flag: number): boolean{
flag = 1 << flag;
return (self & flag) != 0;
}

View File

@@ -41,16 +41,6 @@ class Rectangle extends egret.Rectangle {
this.top < value.bottom;
}
/**
* 判断点是否在矩形内
* @param value
*/
public containsInVec(value: Vector2) {
return ((((this.x <= value.x) && (value.x < (this.x + this.width))) &&
(this.y <= value.y)) &&
(value.y < (this.y + this.height)));
}
/**
* 获取所提供的矩形是否在此矩形的边界内
* @param value
@@ -89,7 +79,7 @@ class Rectangle extends egret.Rectangle {
res.y = MathHelper.clamp(point.y, this.top, this.bottom);
// 如果点在矩形内我们需要推res到边界因为它将在矩形内
if (this.containsInVec(res)) {
if (this.contains(res.x, res.y)) {
let dl = res.x - this.left;
let dr = this.right - res.x;
let dt = res.y - this.top;