Skip to content

ParticleEmitter speedX and speedY Not Updating After Initial Creation #6877

@monteiz

Description

@monteiz

Version

  • Phaser Version: 3.85.0-beta.2

After creating a ParticleEmitter, subsequent changes to the emitter's speedX and speedY properties are not taken into account. Below is a minimal example demonstrating this issue. When the emitter is triggered on a pointer down event, the speed is supposed to be set to zero, but the particles still maintain their initial speed.

Example Test Code

To be pasted in this example:

class Example extends Phaser.Scene
{
    preload ()
    {
        this.load.atlas('flares', 'assets/particles/flares.png', 'assets/particles/flares.json');
    }

    create ()
    {
        const emitter = this.add.particles(400, 250, 'flares', {
            frame: [ 'red', 'yellow', 'green' ],
            lifespan: 4000,
            speed: { min: 150, max: 250 },
            scale: { start: 0.8, end: 0 },
            gravityY: 150,
            blendMode: 'ADD',
            emitting: false
        });

        this.input.on('pointerdown', pointer => {

            emitter.explode(16);

            // Attempt to change particle speed to zero
            emitter.speedX = 0;
            emitter.speedY = 0;
            emitter.setParticleSpeed(0,0);

        });

        this.add.text(10, 10, 'Click to explode emit particles');
    }
}

const config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    backgroundColor: '#000',
    parent: 'phaser-example',
    scene: Example
};

const game = new Phaser.Game(config);

Expected Behavior:

When the emitter is triggered by the pointer down event, the particle speed should be updated to the new values set (speedX and speedY to 0), resulting in particles emitting with no horizontal or vertical speed.

Actual Behavior:

Despite setting speedX and speedY to 0, the particles still emit with their initial speed values.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions