box重载overlaps
This commit is contained in:
@@ -43,6 +43,7 @@ class BoxCollider extends Collider {
|
||||
constructor(){
|
||||
super();
|
||||
|
||||
// 我们在这里插入一个1x1框作为占位符,直到碰撞器在下一阵被添加到实体并可以获得更精确的自动调整大小数据
|
||||
this.shape = new Box(1, 1);
|
||||
this._colliderRequiresAutoSizing = true;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ class Mover extends Component {
|
||||
let bounds = collider.bounds;
|
||||
bounds.x += motion.x;
|
||||
bounds.y += motion.y;
|
||||
let neighbors = Physics.boxcastBroadphaseExcludingSelf(collider, bounds, collider.collidesWithLayers);
|
||||
let boxcastResult = Physics.boxcastBroadphaseExcludingSelf(collider, bounds, collider.collidesWithLayers);
|
||||
bounds = boxcastResult.bounds;
|
||||
let neighbors = boxcastResult.tempHashSet;
|
||||
|
||||
for (let j = 0; j < neighbors.length; j ++){
|
||||
let neighbor = neighbors[j];
|
||||
@@ -42,7 +44,7 @@ class Mover extends Component {
|
||||
|
||||
ListPool.free(colliders);
|
||||
|
||||
return collisionResult;
|
||||
return {collisionResult: collisionResult, motion: motion};
|
||||
}
|
||||
|
||||
public applyMovement(motion: Vector2){
|
||||
@@ -53,7 +55,9 @@ class Mover extends Component {
|
||||
}
|
||||
|
||||
public move(motion: Vector2){
|
||||
let collisionResult = this.calculateMovement(motion);
|
||||
let movementResult = this.calculateMovement(motion);
|
||||
let collisionResult = movementResult.collisionResult;
|
||||
motion = movementResult.motion;
|
||||
|
||||
this.applyMovement(motion);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user