Issues when adding a new Scene with



I’m having an issue when I load a new Scene. I’m calling a PopupScene in 2 differents ways. One work, but not the other.

This is the code adding the Scene :

    showPopup(popup_type) {

        var popup = new PopupScene(popup_type);
        this.scene.add("popup_" + popup_type, popup, true);
        if ( != undefined) {
  "ButtonPopupClicked").on("ButtonPopupClicked", this.onPopupButtonClicked, this);

If works perfectly when I call this on a button pressed. But when I call it from a tween using onComplete, the is always undefined (in the console.log).

Do you have any ideas why?

EDIT: While testing further, I saw that the init method in my scene is called after when it’s added in the tween.

EDIT 2: This is the steps when I click on a button to add the scene:

  • scene constructor called
  • called this.scene.add
  • scene create and init called
    - is not undefined

When I call it from my tween onComplete, or in the update() method :

  • scene constructor called
  • called this.scene.add
    - is undefined
  • scene create and init called

Is it possible to force the SceneManager to refresh manually after I used add with the autoStart param to true?


Where do you first define the ButtonPopupClicked event? Do you just turn it on and off here?