# A scene restarted but the image is still display

**URL:** <https://phaser.discourse.group/t/a-scene-restarted-but-the-image-is-still-display/7192>\
**Category:** Phaser 3\
**Created:** [August 15, 2020, 1:31pm UTC](https://phaser.discourse.group/t/a-scene-restarted-but-the-image-is-still-display/7192 "2020-08-15T13:31:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Datvimaru50](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/datvimaru50/32/3873_2.png) [@Datvimaru50](https://phaser.discourse.group/u/Datvimaru50)\
**Post date:** [August 15, 2020, 1:31pm UTC](https://phaser.discourse.group/t/a-scene-restarted-but-the-image-is-still-display/7192/1 "2020-08-15T13:31:12Z")

</div>

Hi everyone,

I tried to restart a scene with a new data. I found that the timer event on that scene reset correctly but the images from the old scene still display instead of new image I want to render. Is this a bug? Here my code:

```
        // I have 2 scene: Menu and Play. 

        // The Menu scene have a Play button, when clicked, game moved to Play scene

        this.PLAY_BUTTON.on("pointerdown", function(pointer){

            if(this.FIRST_TIME) {

                this.scene.start(CST.SCENES.PLAY, this.SELECTED_TYPE);

                this.scene.setVisible(true, CST.SCENES.PLAY);

                console.log('first load');

            } else {

                if (this.SELECTED_TYPE != this.CURRENT_TYPE) {

                    this.scene.stop(); // stop the menu scene

                    var getPlayScene = this.scene.get(CST.SCENES.PLAY); // get the play scene

                    getPlayScene.scene.restart(this.SELECTED_TYPE); // reset the play scene

                    this.scene.setVisible(true, CST.SCENES.PLAY);

                    console.log('update');

                } else {

                    this.scene.stop();

                    this.scene.resume(CST.SCENES.PLAY);

                    this.scene.setVisible(true, CST.SCENES.PLAY);

                    console.log(

                        'resume'

                    );

                }

            }

        }, this);

    }
```

---

<div class="post-metadata">

**Author:** ![Thyebe](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thyebe/32/3799_2.png) [@Thyebe](https://phaser.discourse.group/u/Thyebe)\
**Post date:** [August 15, 2020, 1:58pm UTC](https://phaser.discourse.group/t/a-scene-restarted-but-the-image-is-still-display/7192/2 "2020-08-15T13:58:41Z")

</div>

Please, put the piece of code that you call to restart scene.

---

<div class="post-metadata">

**Author:** ![Datvimaru50](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/datvimaru50/32/3873_2.png) [@Datvimaru50](https://phaser.discourse.group/u/Datvimaru50)\
**Post date:** [August 15, 2020, 2:27pm UTC](https://phaser.discourse.group/t/a-scene-restarted-but-the-image-is-still-display/7192/3 "2020-08-15T14:27:26Z")

</div>

I update my code to question. Please review!

---

<div class="post-metadata">

**Author:** ![Thyebe](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thyebe/32/3799_2.png) [@Thyebe](https://phaser.discourse.group/u/Thyebe)\
**Post date:** [August 15, 2020, 5:15pm UTC](https://phaser.discourse.group/t/a-scene-restarted-but-the-image-is-still-display/7192/4 "2020-08-15T17:15:05Z")

</div>

Ok. Thanks.

Some more questions:

1. How many scenes do you have in the game?
2. What scene this code is inside?

Maybe this example could help you with this problem

> **[Phaser - Examples - Changing Scene](https://phaser.io/examples/v3/view/scenes/changing-scene#)**
>
> Desktop and Mobile HTML5 game framework. A fast, free and fun open source framework for Canvas and WebGL powered browser games.

---

<div class="post-metadata">

**Author:** ![Datvimaru50](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/datvimaru50/32/3873_2.png) [@Datvimaru50](https://phaser.discourse.group/u/Datvimaru50)\
**Post date:** [August 16, 2020, 12:34am UTC](https://phaser.discourse.group/t/a-scene-restarted-but-the-image-is-still-display/7192/5 "2020-08-16T00:34:36Z")

</div>

1. I have only 2 scenes: Menu Scene and Play Scene
2. This snippet is in the Menu Scene

---

<div class="post-metadata">

**Author:** ![Thyebe](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thyebe/32/3799_2.png) [@Thyebe](https://phaser.discourse.group/u/Thyebe)\
**Post date:** [August 16, 2020, 1:09am UTC](https://phaser.discourse.group/t/a-scene-restarted-but-the-image-is-still-display/7192/6 "2020-08-16T01:09:59Z")

</div>

Well,  
My suggestion is to keep the code that call play scene in the “create” method of the menu scene and put both codes that call the menu scene and that call restart play scene inside the “create” method of the play scene.

Of course, you will need to insert one button in each scene.

Obs:  
I don’t use scene.setVisible(…) in my games, as the example didn’t mention that to change scenes.

And I think you don’t need to call scene.stop() before start another scene.

Hope this help!

---

<div class="post-metadata">

**Author:** ![Datvimaru50](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/datvimaru50/32/3873_2.png) [@Datvimaru50](https://phaser.discourse.group/u/Datvimaru50)\
**Post date:** [August 16, 2020, 1:42am UTC](https://phaser.discourse.group/t/a-scene-restarted-but-the-image-is-still-display/7192/7 "2020-08-16T01:42:40Z")

</div>

Yeah, I put both in the create() method. The setVisible() mehthod I use because I have button to click back to Menu Scene from Play Scene.

The problem is, although the timer event reset correctly but the image in the old screen still display

---

<div class="post-metadata">

**Author:** ![Thyebe](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thyebe/32/3799_2.png) [@Thyebe](https://phaser.discourse.group/u/Thyebe)\
**Post date:** [August 16, 2020, 1:59am UTC](https://phaser.discourse.group/t/a-scene-restarted-but-the-image-is-still-display/7192/8 "2020-08-16T01:59:26Z")

</div>

Ok. Can we keep this conversation by email?  
I think it could be more productive. My email is [thieberson@outlook.com](mailto:thieberson@outlook.com)
