# Problem switching / restarting scene

**URL:** <https://phaser.discourse.group/t/problem-switching-restarting-scene/844>\
**Category:** Phaser 3\
**Created:** [January 20, 2019, 12:16pm UTC](https://phaser.discourse.group/t/problem-switching-restarting-scene/844 "2019-01-20T12:16:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbonneau](https://avatars.discourse-cdn.com/v4/letter/p/e68b1a/32.png) [@paulbonneau](https://phaser.discourse.group/u/paulbonneau)\
**Post date:** [January 20, 2019, 12:16pm UTC](https://phaser.discourse.group/t/problem-switching-restarting-scene/844/1 "2019-01-20T12:16:23Z")

</div>

Hi everyone !  
I experiment a strange problem, when I try to transition to another scene using this.scene.start(‘nameOfTheScene’);  
I get a black screen without the text contained into this scene.

Also, if I try a this.scene.restart() I have the following errors :  
TypeError: this.frame.source is null  
TypeError: this.source is null

Does someone already experiments problems like this ?  
the pen ([https://codepen.io/paulbonneau/pen/OrKgvR](https://codepen.io/paulbonneau/pen/OrKgvR))

I use matter.js as physics engine for the record

---

<div class="post-metadata">

**Author:** ![prob](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/prob/32/628_2.png) [@prob](https://phaser.discourse.group/u/prob)\
**Post date:** [January 20, 2019, 2:03pm UTC](https://phaser.discourse.group/t/problem-switching-restarting-scene/844/2 "2019-01-20T14:03:36Z")

</div>

From a quick glance, it looks like your scene keys don’t match. You might also want to log out your scene list order.

---

<div class="post-metadata">

**Author:** ![paulbonneau](https://avatars.discourse-cdn.com/v4/letter/p/e68b1a/32.png) [@paulbonneau](https://phaser.discourse.group/u/paulbonneau)\
**Post date:** [January 20, 2019, 2:18pm UTC](https://phaser.discourse.group/t/problem-switching-restarting-scene/844/3 "2019-01-20T14:18:52Z")

</div>

Even when I’ve got the exact same string for the key i call in my transition / switch. I get a black screen.

I also tried to match the key name with the “Class” name of my scene but it doesn’t solve the problem.

How the scene order could affect scene called with keys ? I tried to modify the order but it doesn’t change the behavior.

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [January 20, 2019, 5:59pm UTC](https://phaser.discourse.group/t/problem-switching-restarting-scene/844/4 "2019-01-20T17:59:38Z")

</div>

https://codepen.io/samme/embed/preview/aPeggM?height=300&slug-hash=aPeggM&default-tabs=js,result&host=https://codepen.io

---

<div class="post-metadata">

**Author:** ![paulbonneau](https://avatars.discourse-cdn.com/v4/letter/p/e68b1a/32.png) [@paulbonneau](https://phaser.discourse.group/u/paulbonneau)\
**Post date:** [January 26, 2019, 10:12am UTC](https://phaser.discourse.group/t/problem-switching-restarting-scene/844/5 "2019-01-26T10:12:51Z")

</div>

Hi ! Thank you very much for your correction. If I understand it correctly, the problem was that I didn’t used a capital S for Phaser.Scene in my scene declaration.

And thanks for the debug method of scene, I didn’t find the way to debug efficiently in Phaser 3:  
callbacks: {  
postBoot: function (game) {  
game.scene.dump();  
}  
}

A last question. When I try to restart my first scene (the one where the game is) I get the following error :  
TypeError: this.frame.source is null  
TypeError: this.source is null

Do you know where could it come from or at least how I could debug this one ?

---

<div class="post-metadata">

**Author:** ![digitsensitive](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/digitsensitive/32/349_2.png) [@digitsensitive](https://phaser.discourse.group/u/digitsensitive)\
**Post date:** [January 26, 2019, 10:42am UTC](https://phaser.discourse.group/t/problem-switching-restarting-scene/844/6 "2019-01-26T10:42:27Z")

</div>

Have a look at the following two World Issues about scenes. This might help you to understand the concepts behind scenes.

- [Phaser World Issue 120](https://madmimi.com/p/2c1afb)
- [Phaser World Issue 121](https://madmimi.com/p/860f1c)

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [January 27, 2019, 2:56am UTC](https://phaser.discourse.group/t/problem-switching-restarting-scene/844/7 "2019-01-27T02:56:16Z")

</div>

> [@paulbonneau](#):
>
> When I try to restart my first scene (the one where the game is) I get the following error

That’s happening because the destroyed text object is still receiving the scene’s `addScore` event and trying to draw. Do something like:

```
this.events.off('addScore');
this.scene.restart();

```

Scene event listeners aren’t cleared when the scene is shutdown (stopped, restarted). It’s a tricky point.

---

<div class="post-metadata">

**Author:** ![psymeons](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/psymeons/32/4732_2.png) [@psymeons](https://phaser.discourse.group/u/psymeons)\
**Post date:** [January 29, 2021, 9:17am UTC](https://phaser.discourse.group/t/problem-switching-restarting-scene/844/8 "2021-01-29T09:17:25Z")

</div>

I know this is an old post, but you just saved my day. Thanks a lot for this reply!
