修复 triggerlistener 发生碰撞后不断触发问题(仅第一次碰撞触发)

This commit is contained in:
YHH
2020-06-18 09:06:59 +08:00
parent 18279d16cd
commit bc995e36c2
11 changed files with 119 additions and 88 deletions

View File

@@ -94,8 +94,10 @@ class SpatialHash {
if (collider == excludeCollider || !Flags.isFlagSet(layerMask, collider.physicsLayer))
continue;
if (bounds.intersects(collider.bounds))
this._tempHashSet.push(collider);
if (bounds.intersects(collider.bounds)){
if (this._tempHashSet.indexOf(collider) == -1)
this._tempHashSet.push(collider);
}
}
}
}
@@ -157,14 +159,6 @@ class NumberDictionary {
return this._store.get(this.getKey(x, y));
}
public getAllObjects(): Collider[] {
let set: Collider[] = [];
this._store.forEach(list => set.concat(list));
return set;
}
public clear() {
this._store.clear();
}