@@ -89,47 +89,50 @@ paused physics will **NOT** work for it by default. As stated earlier this is
8989because the physics servers are turned off. The physics servers can be made
9090active while the game is paused by using their ``set_active `` methods.
9191
92- Pause Menu Example
92+ Pause menu example
9393------------------
9494
95- Here is an example of a pause menu. Create a popup or panel with controls
96- inside, and set its pause mode to "When Paused" then hide it. By setting the
97- root of the pause popup to "When Paused", all children and grandchildren will
98- inherit that state. This way, this branch of the scene tree will continue
99- working when paused.
95+ Start by creating a button that will be used to pause the game.
10096
101- Finally, make it so when a pause button is pressed (any button will do),
102- enable the pause and show the pause screen.
97+ Create a menu containing a close button, set the **Process Mode ** of the menu's root node
98+ to **When Paused **, then hide the menu. Since the process mode is set to **When Paused **
99+ on the root node, all its children and grandchildren will inherit that process mode.
100+ This way, all the nodes in the menu will start processing when the game is paused.
101+
102+ Attach a script to the menu's root node, connect the pause button created earlier to a new method in
103+ the script, and inside that method pause the game and show the pause menu.
103104
104105.. tabs ::
105106 .. code-tab :: gdscript GDScript
106107
107108 func _on_pause_button_pressed():
108109 get_tree().paused = true
109- $pause_popup. show()
110+ show()
110111
111112 .. code-tab :: csharp
112113
113- public void _on_pause_button_pressed ()
114+ private void OnPauseButtonPressed ()
114115 {
115116 GetTree().Paused = true;
116- GetNode<Control>("pause_popup"). Show();
117+ Show();
117118 }
118119
119- To unpause, do the opposite when the pause screen is
120- closed:
120+ Finally, connect the menu's close button to a new method in the script. Inside that method,
121+ unpause the game and hide the pause menu.
121122
122123.. tabs ::
123124 .. code-tab :: gdscript GDScript
124125
125- func _on_pause_popup_close_pressed ():
126- $pause_popup. hide()
126+ func _on_close_button_pressed ():
127+ hide()
127128 get_tree().paused = false
128129
129130 .. code-tab :: csharp
130131
131- public void _on_pause_popup_close_pressed ()
132+ private void OnCloseButtonPressed ()
132133 {
133- GetNode<Control>("pause_popup"). Hide();
134+ Hide();
134135 GetTree().Paused = false;
135136 }
137+
138+ You should now have a working pause menu.
0 commit comments