Browse Source

added even more fades

Arnaud Vergnet 9 months ago
parent
commit
2cbb6d1414
5 changed files with 80 additions and 19 deletions
  1. 4
    0
      scenes/ExitScene.gd
  2. 12
    0
      scenes/ExitScene.tscn
  3. 1
    1
      scenes/MainMenu.gd
  4. 28
    4
      scenes/PauseMenu.gd
  5. 35
    14
      scenes/PauseMenu.tscn

+ 4
- 0
scenes/ExitScene.gd View File

@@ -0,0 +1,4 @@
1
+extends ColorRect
2
+
3
+func _ready():
4
+	get_tree().quit(0)

+ 12
- 0
scenes/ExitScene.tscn View File

@@ -0,0 +1,12 @@
1
+[gd_scene load_steps=2 format=2]
2
+
3
+[ext_resource path="res://scenes/ExitScene.gd" type="Script" id=1]
4
+
5
+[node name="ExitScene" type="ColorRect"]
6
+anchor_right = 1.0
7
+anchor_bottom = 1.0
8
+color = Color( 0, 0, 0, 1 )
9
+script = ExtResource( 1 )
10
+__meta__ = {
11
+"_edit_use_anchors_": false
12
+}

+ 1
- 1
scenes/MainMenu.gd View File

@@ -29,7 +29,7 @@ func _on_ContinueButton_pressed():
29 29
 
30 30
 
31 31
 func _on_ExitButton_pressed():
32
-	get_tree().quit(0)
32
+	Transit.change_scene("res://scenes/ExitScene.tscn", 0.2)
33 33
 
34 34
 
35 35
 func _on_CreditsButton_pressed():

+ 28
- 4
scenes/PauseMenu.gd View File

@@ -1,21 +1,40 @@
1 1
 extends Control
2 2
 
3
+onready var panel := $MarginContainer/Panel
4
+onready var background := $Background
5
+onready var tween := $Tween
6
+
7
+var animation_speed = 0.4
8
+
3 9
 func load_main_menu():
4 10
 	Transit.change_scene("res://scenes/MainMenu.tscn", 0.5)
5 11
 
6 12
 
7 13
 func pause():
8
-	get_tree().paused = true
9
-	show()
14
+	if not get_tree().paused:
15
+		get_tree().paused = true
16
+		show()
17
+		tween.stop_all()
18
+		tween.interpolate_property(background, "modulate",  null, Color(1, 1, 1, 1), 2*animation_speed/3, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
19
+		tween.interpolate_property(panel, "modulate",  null, Color(1, 1, 1, 1), animation_speed, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
20
+		tween.start()
10 21
 
11 22
 
12 23
 func unpause():
13
-	get_tree().paused = false
14
-	hide()
24
+	if get_tree().paused:
25
+		get_tree().paused = false
26
+		tween.stop_all()
27
+		tween.interpolate_property(background, "modulate",  null, Color(1, 1, 1, 0), animation_speed/2, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
28
+		tween.interpolate_property(panel, "modulate",  null, Color(1, 1, 1, 0), animation_speed/2, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
29
+		tween.start()
15 30
 
16 31
 
17 32
 func _ready():
33
+	panel.modulate = Color(1, 1, 1, 0)
34
+	background.modulate = Color(1, 1, 1, 0)
18 35
 	connect("gui_input", self, '_on_gui_input')
36
+	tween.connect("tween_all_completed", self, "_on_Tween_tween_all_completed")
37
+
19 38
 
20 39
 func _input(event: InputEvent):
21 40
 	if event.is_action_pressed("ui_cancel") and visible:
@@ -37,3 +56,8 @@ func _on_ContinueButton_pressed():
37 56
 func _on_MenuButton_pressed():
38 57
 	unpause()
39 58
 	load_main_menu()
59
+
60
+
61
+func _on_Tween_tween_all_completed():
62
+	if panel.modulate == Color(1, 1, 1, 0):
63
+		hide()

+ 35
- 14
scenes/PauseMenu.tscn View File

@@ -1,10 +1,28 @@
1
-[gd_scene load_steps=6 format=2]
1
+[gd_scene load_steps=7 format=2]
2 2
 
3 3
 [ext_resource path="res://scenes/PauseMenu.gd" type="Script" id=1]
4 4
 [ext_resource path="res://images/pause.png" type="Texture" id=2]
5 5
 [ext_resource path="res://scenes/typo/Button.tscn" type="PackedScene" id=3]
6 6
 [ext_resource path="res://fonts/open-sans/OpenSans-Light.ttf" type="DynamicFontData" id=4]
7 7
 
8
+[sub_resource type="StyleBoxFlat" id=3]
9
+content_margin_left = 0.0
10
+content_margin_right = 0.0
11
+content_margin_top = 0.0
12
+content_margin_bottom = 0.0
13
+bg_color = Color( 0.160784, 0.152941, 0.180392, 1 )
14
+border_width_left = 4
15
+border_width_top = 4
16
+border_width_right = 4
17
+border_width_bottom = 4
18
+corner_radius_top_left = 10
19
+corner_radius_top_right = 10
20
+corner_radius_bottom_right = 10
21
+corner_radius_bottom_left = 10
22
+shadow_color = Color( 0, 0, 0, 0.392157 )
23
+shadow_size = 40
24
+shadow_offset = Vector2( 10, 10 )
25
+
8 26
 [sub_resource type="DynamicFont" id=1]
9 27
 size = 50
10 28
 font_data = ExtResource( 4 )
@@ -22,7 +40,7 @@ __meta__ = {
22 40
 [node name="Background" type="ColorRect" parent="."]
23 41
 anchor_right = 1.0
24 42
 anchor_bottom = 1.0
25
-color = Color( 0, 0, 0, 0.196078 )
43
+color = Color( 0, 0, 0, 0.27451 )
26 44
 __meta__ = {
27 45
 "_edit_use_anchors_": false
28 46
 }
@@ -30,6 +48,7 @@ __meta__ = {
30 48
 [node name="BackgroundButton" type="TextureButton" parent="."]
31 49
 anchor_right = 1.0
32 50
 anchor_bottom = 1.0
51
+mouse_default_cursor_shape = 2
33 52
 expand = true
34 53
 __meta__ = {
35 54
 "_edit_use_anchors_": false
@@ -47,14 +66,14 @@ __meta__ = {
47 66
 "_edit_use_anchors_": false
48 67
 }
49 68
 
50
-[node name="ColorRect" type="ColorRect" parent="MarginContainer"]
69
+[node name="Panel" type="Panel" parent="MarginContainer"]
51 70
 margin_left = 400.0
52 71
 margin_top = 100.0
53 72
 margin_right = 1520.0
54 73
 margin_bottom = 980.0
55
-color = Color( 0.164706, 0.180392, 0.196078, 1 )
74
+custom_styles/panel = SubResource( 3 )
56 75
 
57
-[node name="MarginContainer2" type="MarginContainer" parent="MarginContainer/ColorRect"]
76
+[node name="MarginContainer2" type="MarginContainer" parent="MarginContainer/Panel"]
58 77
 anchor_right = 1.0
59 78
 anchor_bottom = 1.0
60 79
 custom_constants/margin_right = 50
@@ -65,7 +84,7 @@ __meta__ = {
65 84
 "_edit_use_anchors_": false
66 85
 }
67 86
 
68
-[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/ColorRect/MarginContainer2"]
87
+[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/Panel/MarginContainer2"]
69 88
 margin_left = 50.0
70 89
 margin_top = 50.0
71 90
 margin_right = 1070.0
@@ -74,17 +93,17 @@ __meta__ = {
74 93
 "_edit_use_anchors_": false
75 94
 }
76 95
 
77
-[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/ColorRect/MarginContainer2/VBoxContainer"]
96
+[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/Panel/MarginContainer2/VBoxContainer"]
78 97
 margin_right = 1020.0
79 98
 margin_bottom = 64.0
80 99
 
81
-[node name="TextureRect" type="TextureRect" parent="MarginContainer/ColorRect/MarginContainer2/VBoxContainer/CenterContainer"]
100
+[node name="TextureRect" type="TextureRect" parent="MarginContainer/Panel/MarginContainer2/VBoxContainer/CenterContainer"]
82 101
 margin_left = 478.0
83 102
 margin_right = 542.0
84 103
 margin_bottom = 64.0
85 104
 texture = ExtResource( 2 )
86 105
 
87
-[node name="Text" type="Label" parent="MarginContainer/ColorRect/MarginContainer2/VBoxContainer"]
106
+[node name="Text" type="Label" parent="MarginContainer/Panel/MarginContainer2/VBoxContainer"]
88 107
 margin_top = 68.0
89 108
 margin_right = 1020.0
90 109
 margin_bottom = 724.0
@@ -94,26 +113,28 @@ text = "Le jeu est en pause"
94 113
 align = 1
95 114
 valign = 1
96 115
 
97
-[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/ColorRect/MarginContainer2/VBoxContainer"]
116
+[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer2/VBoxContainer"]
98 117
 margin_top = 728.0
99 118
 margin_right = 1020.0
100 119
 margin_bottom = 780.0
101 120
 custom_constants/separation = 50
102 121
 alignment = 1
103 122
 
104
-[node name="MenuButton" parent="MarginContainer/ColorRect/MarginContainer2/VBoxContainer/HBoxContainer" instance=ExtResource( 3 )]
123
+[node name="MenuButton" parent="MarginContainer/Panel/MarginContainer2/VBoxContainer/HBoxContainer" instance=ExtResource( 3 )]
105 124
 margin_left = 355.0
106 125
 margin_top = 0.0
107 126
 margin_right = 455.0
108 127
 margin_bottom = 52.0
109 128
 text = "Menu"
110 129
 
111
-[node name="ContinueButton" parent="MarginContainer/ColorRect/MarginContainer2/VBoxContainer/HBoxContainer" instance=ExtResource( 3 )]
130
+[node name="ContinueButton" parent="MarginContainer/Panel/MarginContainer2/VBoxContainer/HBoxContainer" instance=ExtResource( 3 )]
112 131
 margin_left = 505.0
113 132
 margin_top = 0.0
114 133
 margin_right = 664.0
115 134
 margin_bottom = 52.0
116 135
 text = "Continuer"
136
+
137
+[node name="Tween" type="Tween" parent="."]
117 138
 [connection signal="pressed" from="BackgroundButton" to="." method="_on_BackgroundButton_pressed"]
118
-[connection signal="pressed" from="MarginContainer/ColorRect/MarginContainer2/VBoxContainer/HBoxContainer/MenuButton" to="." method="_on_MenuButton_pressed"]
119
-[connection signal="pressed" from="MarginContainer/ColorRect/MarginContainer2/VBoxContainer/HBoxContainer/ContinueButton" to="." method="_on_ContinueButton_pressed"]
139
+[connection signal="pressed" from="MarginContainer/Panel/MarginContainer2/VBoxContainer/HBoxContainer/MenuButton" to="." method="_on_MenuButton_pressed"]
140
+[connection signal="pressed" from="MarginContainer/Panel/MarginContainer2/VBoxContainer/HBoxContainer/ContinueButton" to="." method="_on_ContinueButton_pressed"]

Loading…
Cancel
Save