修复 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

@@ -20,7 +20,8 @@ class EntityList{
}
public add(entity: Entity){
this._entitiesToAdded.push(entity);
if (this._entitiesToAdded.indexOf(entity) == -1)
this._entitiesToAdded.push(entity);
}
public remove(entity: Entity){
@@ -108,10 +109,12 @@ class EntityList{
this._entitiesToAdded = this._tempEntityList;
this._tempEntityList = temp;
this._tempEntityList.forEach(entity => {
this._entities.push(entity);
entity.scene = this.scene;
if (!this._entities.contains(entity)){
this._entities.push(entity);
entity.scene = this.scene;
this.scene.entityProcessors.onEntityAdded(entity)
this.scene.entityProcessors.onEntityAdded(entity)
}
});
this._tempEntityList.forEach(entity => entity.onAddedToScene());