• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

[Tạo 2D Platformer Game với Godot] Part 24: Creating a Pause Menu

AnonyViet by AnonyViet
January 26, 2023
in Tips
0

In this part, I will guide you how to create a pause menu while playing a game and press pause then the game stops and you can continue playing, playing again, exiting.

Join the channel Telegram of the AnonyViet 👉 Link 👈

And create a menu when the game ends, it includes: Next Level, Play again, exit the menu.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 43

I add CanvasLayer as the root node and rename it as PauseMenu

[Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 44

Because it’s quite small, I adjusted the min size up.
[Tạo 2D Platformer Game với Godot]  Part 24: Creating a 45 . Pause Menu

It got bigger when the min size was adjusted and in the text box I added 2 signs | |

[Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 46

Then I added a Custom Font to make it beautiful.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 47

Color id: a77322

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 48

Then add custom Styles to make it pleasing to the eye.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 49

And I have the above result[Tạo 2D Platformer Game với Godot]  Part 24: Creating a 50 . Pause Menu [Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 51

I added a new Control node and renamed it PauseMenu and added a Panel to be the Background then renamed it.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating the Pause Menu 52

Then align to the center
[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 53

I created a new Custom styles.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 54

Color: a89d24[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 55

Above are the parameters.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 56 [Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 57

You add the MarginConTainer node under the Background.

I use margincontainer to align it beautifully.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 58

Select Full rect

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 59

Then Theme Overrides -> Constants you fill in about 10 and customize according to your game.[Tạo 2D Platformer Game với Godot]  Part 24: Creating a 60 . Pause Menu

Add a Vboxcontainer

[Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 61

After adding you will see the Vboxcontainer is indented 10mm from the margincontainer.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 62

Add the Label rename as TieuDe

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 63

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 64

Adjust align to Center to center

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a 65 . Pause Menu

Add a custom font to make it beautiful[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 66

Result as above.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 67

I added 3 more buttons like the picture and 3 Ninepatchrect as spaces.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 68

Then you add custom fonts and custom styles to the button.

You can add or not add.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 69

You save the scene

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a 70 . Pause Menu [Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 71

Add a script in the PauseMenu node

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 72

Then connect 4 signals of 4 buttons.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 73

Then hide the pause menu because I only show it when I press the show button.

func _on_NutTiepTuc_pressed():
    get_tree().paused = false
    $PauseMenu.hide()

Code in continue button.

get_tree().paused = false : I will tell the tree to continue working.

$PauseMenu.hide() : I will hide the PauseMenu because I want to continue playing the game.

func _on_NutChoiLai_pressed():
	get_tree().paused = false
	get_tree().reload_current_scene()
	pass # Replace with function body.


get_tree().reload_current_scene() : I will tell the tree to replay the scene.

func _on_NutVeMenu_pressed():
    get_tree().paused = false
    get_tree().change_scene("res://Scences/Map/LevelMap.tscn")
    pass # Replace with function body.

get_tree().change_scene("res://Scences/Map/LevelMap.tscn"): I will move to the Level Map scene.

func _on_HienPauseMenu_pressed():
    $PauseMenu.show()
    get_tree().paused = true
    pass # Replace with function body.

$PauseMenu.show() : is that I will show the PauseMenu because it is hidden.

get_tree().paused = true : is that I will call the current tree and tell it to stop. When stopped, all nodes on the tree will stop working.

extends CanvasLayer



func _on_NutTiepTuc_pressed():
    get_tree().paused = false
    $PauseMenu.hide()



func _on_NutChoiLai_pressed():
    get_tree().paused = false
    get_tree().reload_current_scene()
    pass # Replace with function body.


func _on_NutVeMenu_pressed():
    get_tree().paused = false
    get_tree().change_scene("res://Scences/Map/LevelMap.tscn")
    pass # Replace with function body.


func _on_HienPauseMenu_pressed():
    $PauseMenu.show()
    get_tree().paused = true
    pass # Replace with function body.

So I will have full code like this.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 74

And in the Inspector’s PauseMenu, you need to change the pause mode to Process so that when the tree pauses, but the PauseMenu still works.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 75

Then Instance to Map.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 76

Here are my results

Level Map

Ah, I forgot in the previous parts to add a return button in the Level map scene to return to the Main Menu.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 77

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 78 [Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 79

You add the Button node and then rename it. Then add custom fonts, custom styles.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 80 [Tạo 2D Platformer Game với Godot]  Part 24: Creating Pause Menu 81

Create your own script at Level Map.

Then connect the signal in the QuayVe node.

extends Node2D


func _on_QuayVe_pressed():
    get_tree().change_scene("res://Scences/UI/Menu.tscn")
    pass # Replace with function body.

About the code I have above.

[Tạo 2D Platformer Game với Godot]  Part 24: Creating a Pause Menu 82

And I have the above result

Summary

So in this part, I showed you how to create a pause menu for the game.

The article achieved: 5/5 – (100 votes)

Tags: creatingGameGodotmenuPartPausePlatformertạovới
Previous Post

MHHDoS – Tool DDoS Attack with 36 hottest attack types 2021

Next Post

How to create free VPS from UCloud without VISA

AnonyViet

AnonyViet

Related Posts

Top 5 game programming languages ​​to learn now
Tips

Top 5 game programming languages ​​to learn now

June 8, 2025
[Godot Shooter] #2: Creating characters & shooting bullets
Tips

[Godot Shooter] #2: Creating characters & shooting bullets

June 7, 2025
What do you need to learn game programming? Is it difficult? How long does it take?
Tips

What do you need to learn game programming? Is it difficult? How long does it take?

June 6, 2025
Instructions for registering chatgpt team at $ 1
Tips

Instructions for registering chatgpt team at $ 1

June 5, 2025
How to engrave the right mouse menu error on Windows
Tips

How to engrave the right mouse menu error on Windows

June 5, 2025
How to create online meme photos is very easy with a few steps
Tips

How to create online meme photos is very easy with a few steps

June 5, 2025
Next Post
How to create free VPS from UCloud without VISA

How to create free VPS from UCloud without VISA

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

Top 5 game programming languages ​​to learn now

Top 5 game programming languages ​​to learn now

June 8, 2025
The iPhone list is updated with iOS 26

The iPhone list is updated with iOS 26

June 8, 2025
Discover the glowing effect next to the iPhone ios 18 screen

Discover the glowing effect next to the iPhone ios 18 screen

June 8, 2025
[Godot Shooter] #2: Creating characters & shooting bullets

[Godot Shooter] #2: Creating characters & shooting bullets

June 7, 2025
Top 5 game programming languages ​​to learn now

Top 5 game programming languages ​​to learn now

June 8, 2025
The iPhone list is updated with iOS 26

The iPhone list is updated with iOS 26

June 8, 2025
Discover the glowing effect next to the iPhone ios 18 screen

Discover the glowing effect next to the iPhone ios 18 screen

June 8, 2025
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

Top 5 game programming languages ​​to learn now

Top 5 game programming languages ​​to learn now

June 8, 2025
The iPhone list is updated with iOS 26

The iPhone list is updated with iOS 26

June 8, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET https://kubet88.yoga/ bj88

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET https://kubet88.yoga/ bj88

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply