Skip to content

Pointerup event propagates to below scene if the interactive of the game object is disabled during the pointerup #6601

@UnaiNeuronUp

Description

@UnaiNeuronUp

Version

  • Phaser Version: 3.60
  • Operating system: Windows 11

Description

When you have 2 scenes with interactive game objects placed in the same position one in each scene.
Object1 => The one placed on the bottom scene.
Object2 => The one placed on the top scene.
When click on object2 the event is not propagated to the click of the object1.

Expected behaviour:

  • If object2 interactive is disabled during the pointerup the click is not propagated to other scenes.
    What actually happens:
  • If object2 interactive is disabled during the pointerup event the click propagates to the bottom scene even if there are other interactive elements on the upper scene.

Additional Info:

  • The event doesnt propagates to gameobjects in the same scene (ok behaviour).

Example Test Code

class Scene1 extends Phaser.Scene {
    create() {
        const redRect = this.add.rectangle(225, 225, 200, 200, 0xff0000).setInteractive();
        redRect.on('pointerup', () => {
            console.log('redRect');
        });

        const blueRect = this.add.rectangle(125, 125, 200, 200, 0x0000ff).setInteractive();
        blueRect.on('pointerup', () => {
            console.log('blueRect');
            blueRect.disableInteractive();
        });

        const whiteRect = this.add.rectangle(675, 125, 200, 200, 0xffffff).setInteractive();
        whiteRect.on('pointerup', () => {
            console.log('whiteRect');
        });
    }
}

class Scene2 extends Phaser.Scene {
    create() {
        const yellowRect = this.add.rectangle(675, 225, 200, 200, 0xffff00).setInteractive().setAlpha(0.8);
        yellowRect.on('pointerup', () => {
            console.log('yellowRect');
        });

        const greenRect = this.add.rectangle(575, 225, 200, 200, 0x00ff00).setInteractive().setAlpha(0.8);
        greenRect.on('pointerup', () => {
            console.log('greenRect');
            greenRect.disableInteractive();
        });
    }
}

const config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    pixelArt: true,
    backgroundColor: '#000022',
    parent: 'phaser-example'
};

const game = new Phaser.Game(config);

const scene1 = new Scene1('scene1');
game.scene.add('scene1', scene1);
Phaser.Scene.call(scene1, { key: 'scene1', active: true });

const scene2 = new Scene2('scene2');
game.scene.add('scene2', scene2);
Phaser.Scene.call(scene2, { key: 'scene2', active: true });

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