Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParticleEmitter speedX and speedY Not Updating After Initial Creation #6877

Open
monteiz opened this issue Jul 28, 2024 · 1 comment
Open

Comments

@monteiz
Copy link
Contributor

monteiz commented Jul 28, 2024

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.

@phaserjs phaserjs deleted a comment from greptile-apps bot Aug 31, 2024
@photonstorm
Copy link
Collaborator

photonstorm commented Aug 31, 2024

In the example you emit the particles and then set the emitter speed to zero. Speed is an onEmit property, not an onUpdate one, so the particles already launched will not be modified by changing the speed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants