Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const emitterLayers: Emitter[] = [];
for (let i = 0; i < layers.length; i++) {
let emitterLayer: Emitter | null = null;
const textureName = layers[i];
if (this.activeEmitters[textureName]) emitterLayer = this.activeEmitters[textureName];
else {
const textureDefinition = RenderedObject.getTextureDefinition(textureName);
if (textureDefinition.emitter) {
const particleTextureName = textureDefinition.particle;
const particleTextures = RenderedObject.loadTexture(RenderedObject.getTextureDefinition(particleTextureName), particleTextureName);
if (typeof textureDefinition.emitter == "string") textureDefinition.emitter = emitters[textureDefinition.emitter];
emitterLayer = new Emitter(this.container.emitterContainer, particleTextures, textureDefinition.emitter);
emitterLayer.emit = true;
emitterLayer.renderedObject = this;
emitterLayer.particleConstructor = GroupParticle;
}
}
if (emitterLayer != null) {
if (zIndex == 0) zIndex = 250;
// emitterLayer.zIndex = 1000 + i - zIndex - this.body.ID / 100000;
emitterLayers.push(emitterLayer);
this.activeEmitters[textureName] = emitterLayer;
}
}
private spawnImpact = (x: number, y: number, color = '#ffffff') => {
new Emitter(
this.playersManager,
[ParticleTextures.particleTexture],
{
...particleConfig,
color: {
start: color,
end: color,
},
pos: {
x,
y,
},
},
).playOnceAndDestroy();
}
constructor() {
super(15000, {
scale: true,
position: true,
rotation: true,
uvs: true,
alpha: true
}, 15000);
this.emitter = new particles.Emitter(this);
this.lastTime = Date.now();
}