fix: remove destroy emitters

This commit is contained in:
cha0s 2019-11-06 00:08:21 -06:00
parent 5cfc18a2aa
commit 7cb4d21f5a

View File

@ -171,13 +171,17 @@ export class Emitter extends decorate(Trait) {
this.entity.emitParticleJson(mergedJson);
count -= 1;
if (count > 0) {
const removeEmission = () => {
const index = this.emissions.indexOf(ticker);
if (-1 !== index) {
this.emissions.splice(index, 1);
}
};
this.entity.on('destroy', removeEmission);
ticker.on('tick', () => {
this.emitParticleJson(mergedJson);
this.entity.emitParticleJson(mergedJson);
if (0 === --count) {
const index = this.emissions.indexOf(ticker);
if (-1 !== index) {
this.emissions.splice(index, 1);
}
removeEmission();
}
});
this.emissions.push(ticker);