Emitter from sprites -> Scale/Anchor Problem

Hi
I am following the example below to add particles when the user clicks on the screen.
Phaser 3 Examples

The problem appears when I want to scale the particles (which I need), the position is lost, because the scaling is not centered (I think).

Adding at the end the following line in the example, what I say happens

    particles.setScale(0.5); //New scale -> Error in position

What happens

:wave:

How do you want to scale the particles?

If you just want smaller particles, decrease the scale values in createEmitter(). Or use ParticleEmitter#setScale.

ParticleEmitterManager#setScale would scale all the emitter coordinates.

Hello, thanks for answering my problem

What is the difference between using the setScale() of the ParticleEmitter and the setScale() of the ParticleEmitterManager? Sorry but I don’t understand if I am using the wrong setScale for my purpose following the example.

Like the example, I first create the particles and later they are emitted when the user activates certain zones and an event is fired. At that moment when the event is fired, I decide the size they will have, that’s why I need to be able to scale them dynamically.

I set 0.5 in setScale (0.5) as an example, but it is a dynamic variable in my real case

ParticleEmitterManager#setScale() scales all of the particle coordinates, like a container. I don’t think you want to use that method here.

You can use ParticleEmitter#setScale(), you just need to save a reference to the emitter first:

var emitter1 = particles.createEmitter(/*…*/);

emitter1.setScale(0.5);

Another way is to pass a function:

var scale = 1;

particles.createEmitter({
  scale: function () { return scale; }
});

scale += 0.1; // etc.

Thank you very much, I have achieved what I needed with this example