fix: remove destroy emitters
This commit is contained in:
parent
5cfc18a2aa
commit
7cb4d21f5a
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user