Browse Source

improve pause menu behavior

Arnaud Vergnet 6 months ago
parent
commit
df6a44bc8e
3 changed files with 12 additions and 4 deletions
  1. 9
    4
      mini-game/scenes/decor/foreground.gd
  2. 1
    0
      scenes/PauseMenu.tscn
  3. 2
    0
      scenes/UI.tscn

+ 9
- 4
mini-game/scenes/decor/foreground.gd View File

@@ -2,18 +2,23 @@ extends Node2D
2 2
 
3 3
 onready var texture : TextureRect = $TextureRect
4 4
 
5
+var force_stop = false
5 6
 var moving = false
6 7
 
7 8
 func stop():
8 9
 	moving = false
10
+	force_stop = true
9 11
 	texture.material.set_shader_param("scroll_speed", 0)
10 12
 
11 13
 func start():
12 14
 	moving = true
15
+	force_stop = false
13 16
 	texture.material.set_shader_param("scroll_speed", 0.2)
14 17
 
15 18
 func _process(delta):
16
-	if get_tree().paused and moving:
17
-		stop()
18
-	elif not get_tree().paused and not moving:
19
-		start()
19
+	if not force_stop:
20
+		if get_tree().paused and moving:
21
+			stop()
22
+			force_stop = false
23
+		elif not get_tree().paused and not moving:
24
+			start()

+ 1
- 0
scenes/PauseMenu.tscn View File

@@ -11,6 +11,7 @@ font_data = ExtResource( 4 )
11 11
 
12 12
 [node name="PauseMenu" type="Control"]
13 13
 pause_mode = 2
14
+visible = false
14 15
 anchor_right = 1.0
15 16
 anchor_bottom = 1.0
16 17
 script = ExtResource( 1 )

+ 2
- 0
scenes/UI.tscn View File

@@ -51,6 +51,8 @@ __meta__ = {
51 51
 margin_left = 1836.0
52 52
 margin_right = 1900.0
53 53
 margin_bottom = 64.0
54
+focus_mode = 0
55
+enabled_focus_mode = 0
54 56
 texture_normal = ExtResource( 1 )
55 57
 
56 58
 [node name="ColorRect" type="ColorRect" parent="MarginContainer/HBoxContainer/TextureButton"]

Loading…
Cancel
Save