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

Phaser.Scenes.ScenePlugin moveBelow swaps scenes regardless of order #6040

Closed
yuupsup opened this issue Mar 12, 2022 · 1 comment
Closed

Comments

@yuupsup
Copy link

yuupsup commented Mar 12, 2022

Version

  • Phaser Version: 3.55.2
  • Operating system: MacOS
  • Browser: Chrome

Description

Scene Order
[SceneA, SceneB]

Invoke the following method:
ScenePlugin.moveBelow(keyA, keyB)

Expected
Scene Order should be retained. [SceneA, SceneB]

Actual
Scenes are swapped even though SceneB is already below SceneA. [SceneB, SceneA]

Example Test Code

class Controller extends Phaser.Scene {

    constructor ()
    {
        super({ key: 'Controller', active: true });
    }

    create ()
    {
        this.input.on('pointerdown', function (pointer) {
            this.scene.moveBelow('SceneA', 'SceneB');
        }, this);
    }
}

class SceneA extends Phaser.Scene {

    constructor ()
    {
        super({ key: 'SceneA', active: true });
    }

    create ()
    {
        this.add.rectangle(340, 300, 64, 64, 0xff33cc);
    }
}

class SceneB extends Phaser.Scene {

    constructor ()
    {
        super({ key: 'SceneB', active: true });
    }

    create ()
    {
        this.add.rectangle(380, 300, 64, 64, 0xbbb3cc);
    }
}

let config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    parent: 'phaser-example',
    scene: [ Controller, SceneA, SceneB ]

    // When left mouse is clicked, SceneA and SceneB will be swapped regardless of the order
};

let game = new Phaser.Game(config);

Additional Information

Solution
I think we would just need to check that the index of the first parameter of the method (keyA) is greater than the index of the second parameter (keyB).

I'm assuming the same issue might occur with the moveAbove as well.

@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

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

No branches or pull requests

2 participants