# How does the menu button pause everything?

**URL:** https://forum.makecode.com/t/how-does-the-menu-button-pause-everything/34108
**Category:** Help
**Created:** [February 25, 2025, 9:54pm UTC](https://forum.makecode.com/t/how-does-the-menu-button-pause-everything/34108 "2025-02-25T21:54:50Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![platformermaster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/platformermaster/32/16102_2.png) [@platformermaster](https://forum.makecode.com/u/platformermaster)
#### Post date: [February 25, 2025, 9:54pm UTC](https://forum.makecode.com/t/how-does-the-menu-button-pause-everything/34108/1 "2025-02-25T21:54:50Z")

</div>

I need to know how the menu button pauses my whole game. I want to create my own pause screen but whenever I do that background sprites still move (unlike the built in menu screen).

---

<div class="post-metadata">

### Author: ![redSprite](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/redsprite/32/34262_2.png) [@redSprite](https://forum.makecode.com/u/redSprite)
#### Post date: [February 26, 2025, 5:49pm UTC](https://forum.makecode.com/t/how-does-the-menu-button-pause-everything/34108/2 "2025-02-26T17:49:31Z")

</div>

I’m pretty sure you want to put EVERY single piece of code into an if block that checks if the main menu is open, if it’s not, run the code.

---

<div class="post-metadata">

### Author: ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)
#### Post date: [February 26, 2025, 5:51pm UTC](https://forum.makecode.com/t/how-does-the-menu-button-pause-everything/34108/3 "2025-02-26T17:51:21Z")

</div>

I think the menu screen is in its own function. If you put a very long loop inside a function, you’ll notice that the whole game freezes until it is done. The only problem is that the whole game freezes, meaning the screen doesn’t update, so making a functioning pause screen wouldn’t really work, at least not if you were only using blocks…  
Of course, if you aren’t using block code, you should take a look in the explorer in Game, Systemmenu.ts and scroll around, you might find out how to do what the system menu does!

---

<div class="post-metadata">

### Author: ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)
#### Post date: [February 26, 2025, 5:51pm UTC](https://forum.makecode.com/t/how-does-the-menu-button-pause-everything/34108/4 "2025-02-26T17:51:25Z")

</div>

Ok, I was kinda curious myself so I did some digging. Turns out that Makecode uses “scenes” to keep track of everything, and there is actually built in functionality to “push” the current scene out somewhere else and then create a new scene. You can then “pop” the old scene back, deleting the second scene you made and replacing it with the old one! These functions haven’t been made into blocks, but if you want to use them in written code they are game.pushScene() and game.popScene()

(The code for these functions in the explorer is in game → game.ts, around line 150)

It would be really annoying to turn this into an extension because, when the current scene is “pushed”, all the “on button pressed” definitions go away with it, so you need to define them again after you push the scene. Block code doesn’t really have a way to re-define those functions, so anyone making an extension would need add that functionality too.

If someone wants to turn this into an extension, be my guest, but it won’t be that simple!

Here’s a small demo I made in JavaScript if anyone wants to play around with it:

> **[pause screen! (JavaScript implementation)](https://arcade.makecode.com/S74235-45617-85777-48631)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

(Hopefully this will get approved after the first message I wrote)

---

<div class="post-metadata">

### Author: ![CodeOnTheCob](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/codeonthecob/32/19306_2.png) [@CodeOnTheCob](https://forum.makecode.com/u/CodeOnTheCob)
#### Post date: [February 26, 2025, 5:58pm UTC](https://forum.makecode.com/t/how-does-the-menu-button-pause-everything/34108/5 "2025-02-26T17:58:54Z")

</div>

hey me too because ngl it kind of looks ungly

---

<div class="post-metadata">

### Author: ![platformermaster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/platformermaster/32/16102_2.png) [@platformermaster](https://forum.makecode.com/u/platformermaster)
#### Post date: [February 27, 2025, 1:31pm UTC](https://forum.makecode.com/t/how-does-the-menu-button-pause-everything/34108/6 "2025-02-27T13:31:09Z")

</div>

And I kinda want to get into extension creating (if you know anything about that) how easy is it and like what is the process?

---

<div class="post-metadata">

### Author: ![platformermaster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/platformermaster/32/16102_2.png) [@platformermaster](https://forum.makecode.com/u/platformermaster)
#### Post date: [February 27, 2025, 2:25pm UTC](https://forum.makecode.com/t/how-does-the-menu-button-pause-everything/34108/7 "2025-02-27T14:25:29Z")

</div>

Okay thanks this is very helpful!

---

<div class="post-metadata">

### Author: ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)
#### Post date: [February 27, 2025, 5:57pm UTC](https://forum.makecode.com/t/how-does-the-menu-button-pause-everything/34108/8 "2025-02-27T17:57:51Z")

</div>

I know a bit about extensions. Basically, you make some useful functions, and then you use a bunch of syntax stuff to tell Makecode how to turn those functions into blocks. I started by opening extensions and looking inside, copying them, and changing around stuff to see how it effected the blocks!
