Skip to content

Phaser.GameObjects.Container inside another Container call addedToScene when the scene is removed only #6078

@BenoitFreslon

Description

@BenoitFreslon

Version

In Phaser 3 example

Browser

  • Browser: Chrome, Safari

Description

Hello

Test this code, tap T to remove the scene and see that the container2.addedToScene event is called when the scene is removed.

Example Test Code

class ContainerTest extends Phaser.GameObjects.Container {
    constructor(scene, x, y) {
		super(scene, 166, 275);
        console.log("container:constructor");
	}

	addedToScene() {
		super.addedToScene()
		console.log("container:addedToScene");
	}
}

var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    backgroundColor: '#010101',
    parent: 'phaser-example',
    scene: {
        preload: preload,
        create: create
    }
};

var game = new Phaser.Game(config);

function preload ()
{

}

function create ()
{
    console.log("create");

    container = this.add.container(400, 300);

    container2 = new ContainerTest(this, 100, 100);
    container.add(container2);

    this.input.keyboard.on("keyup-T", () => {
        console.log("Input detected")
        this.scene.remove();
    })
}

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