# How to resume a scene outside of Phaser?

**URL:** <https://phaser.discourse.group/t/how-to-resume-a-scene-outside-of-phaser/1376>\
**Category:** Phaser 3\
**Created:** [February 24, 2019, 2:41pm UTC](https://phaser.discourse.group/t/how-to-resume-a-scene-outside-of-phaser/1376 "2019-02-24T14:41:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tonio24100](https://avatars.discourse-cdn.com/v4/letter/t/ec9cab/32.png) [@Tonio24100](https://phaser.discourse.group/u/Tonio24100)\
**Post date:** [February 24, 2019, 2:41pm UTC](https://phaser.discourse.group/t/how-to-resume-a-scene-outside-of-phaser/1376/1 "2019-02-24T14:41:43Z")

</div>

Hello,

I need to resume a scene from outside Phaser.  
Is it possible ?

Here is a pen : [https://codepen.io/Tonio24100/pen/QoLLJq](https://codepen.io/Tonio24100/pen/QoLLJq)  
L. 25 : this.scene.pause();  
L. 63 : game.scene.keys.KeySceneA.resume(); (doesn’t work, What is the right way ?)

Thanks in advance,

Anthony

---

<div class="post-metadata">

**Author:** ![Telinc1](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/telinc1/32/60_2.png) [@Telinc1](https://phaser.discourse.group/u/Telinc1)\
**Post date:** [February 24, 2019, 3:04pm UTC](https://phaser.discourse.group/t/how-to-resume-a-scene-outside-of-phaser/1376/2 "2019-02-24T15:04:50Z")

</div>

`game.scene.keys.KeySceneA` will give you the Scene object for the scene, but the actual `resume` method in the Scene Plugin, which is available either as `scene` or `sys.scene` on the Scene object. Try `game.scene.keys.KeySceneA.scene.resume();`.

---

<div class="post-metadata">

**Author:** ![Tonio24100](https://avatars.discourse-cdn.com/v4/letter/t/ec9cab/32.png) [@Tonio24100](https://phaser.discourse.group/u/Tonio24100)\
**Post date:** [February 24, 2019, 3:21pm UTC](https://phaser.discourse.group/t/how-to-resume-a-scene-outside-of-phaser/1376/3 "2019-02-24T15:21:39Z")

</div>

Thanks Telinc1

It doesn’t work too. I also tried int the codepen with :

> game.scene.keys.SceneA.scene.resume();

But it doesn’t work again.

---

<div class="post-metadata">

**Author:** ![Telinc1](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/telinc1/32/60_2.png) [@Telinc1](https://phaser.discourse.group/u/Telinc1)\
**Post date:** [February 24, 2019, 4:17pm UTC](https://phaser.discourse.group/t/how-to-resume-a-scene-outside-of-phaser/1376/4 "2019-02-24T16:17:48Z")

</div>

I took another look at the example; your scene’s key isn’t `SceneA`, it’s `KeySceneA` - the argument you give to the constructor of Phaser.Scene. On theory, it should be `game.scene.keys.KeySceneA.scene.resume();`.

The actual problem, apart from the incorrect scene key and function, is that scenes are initialized after the game boots, not when the game is created. You should run your `resume` function in [the `postBoot` callback of the game config](https://photonstorm.github.io/phaser3-docs/Phaser.Core.Config.html#postBoot). I’m not sure if this will have an effect, either, because you pause the scene in its `create` function, so `postBoot` could be too early.

The better question here is why you want to pause your scene like this and then resume it. It seems quite weird without any context.

---

<div class="post-metadata">

**Author:** ![Tonio24100](https://avatars.discourse-cdn.com/v4/letter/t/ec9cab/32.png) [@Tonio24100](https://phaser.discourse.group/u/Tonio24100)\
**Post date:** [February 24, 2019, 4:39pm UTC](https://phaser.discourse.group/t/how-to-resume-a-scene-outside-of-phaser/1376/5 "2019-02-24T16:39:06Z")

</div>

Thank you Telinc1 for your detailed answer.

My phaser game is in an hidden DIV and I have an animation at the start of my phaser game.  
That’s why I need to pause it immediatly (to stop the animation).  
And I need to resume it when I will show the DIV with (to start the animation).

In the codepen, this is the template I used for my game.

Do you think it’s possible ?

Maybe it’s possible to pause the entire game ?

---

<div class="post-metadata">

**Author:** ![Telinc1](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/telinc1/32/60_2.png) [@Telinc1](https://phaser.discourse.group/u/Telinc1)\
**Post date:** [February 24, 2019, 6:24pm UTC](https://phaser.discourse.group/t/how-to-resume-a-scene-outside-of-phaser/1376/6 "2019-02-24T18:24:40Z")

</div>

You can pause the entire game by pausing the [Time Step](https://photonstorm.github.io/phaser3-docs/Phaser.Core.TimeStep.html), available as `game.loop`, with its `sleep` method, then resuming it with the `wake` method. You’re going to have to play around with the timing here because `postBoot` runs before the Time Step starts, so sleeping it will have no effect. A method that worked in the CodePen was to sleep the Time Step in the `init` method of the Scene, then `wake` it later.

---

<div class="post-metadata">

**Author:** ![Tonio24100](https://avatars.discourse-cdn.com/v4/letter/t/ec9cab/32.png) [@Tonio24100](https://phaser.discourse.group/u/Tonio24100)\
**Post date:** [February 25, 2019, 2:58pm UTC](https://phaser.discourse.group/t/how-to-resume-a-scene-outside-of-phaser/1376/7 "2019-02-25T14:58:59Z")

</div>

Top !  
Thank you very much @Telinc1
