瀏覽代碼

Ajoute menu pause

DricomDragon 11 月之前
父節點
當前提交
7a227977ed

+ 33 - 0
godot/composants/interface/pause/pause_menu.gd

@@ -0,0 +1,33 @@
+extends Control
+
+
+func reprendre() -> void:
+	hide()
+	get_tree().set_pause(false)
+
+
+func _unhandled_input(event: InputEvent) -> void:
+	if event.is_action_released("ui_pause"):
+		if get_tree().is_paused():
+			reprendre()
+		else:
+			get_tree().set_pause(true)
+			show()
+
+
+func _quand_bouton_reprendre_est_presse():
+	reprendre()
+
+
+func _quand_bouton_retour_titre_est_presse():
+	reprendre()
+	get_tree().reload_current_scene()
+
+
+func _quand_bouton_quitter_est_presse():
+	get_tree().quit()
+
+
+func _on_visibility_changed():
+	%Reprendre.grab_focus()
+

+ 44 - 0
godot/composants/interface/pause/pause_menu.tscn

@@ -0,0 +1,44 @@
+[gd_scene load_steps=3 format=3 uid="uid://cvsfngjyx7xvw"]
+
+[ext_resource type="Script" path="res://composants/interface/pause/pause_menu.gd" id="1_c51fd"]
+[ext_resource type="Texture2D" uid="uid://bkupreskydgkg" path="res://composants/interface/pause/sprite.png" id="2_2pxrh"]
+
+[node name="PauseMenu" type="VSplitContainer"]
+process_mode = 3
+visible = false
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+dragger_visibility = 1
+script = ExtResource("1_c51fd")
+
+[node name="PauseTitle" type="TextureRect" parent="."]
+custom_minimum_size = Vector2(0, 300)
+layout_mode = 2
+texture = ExtResource("2_2pxrh")
+stretch_mode = 3
+
+[node name="Buttons" type="VBoxContainer" parent="."]
+process_mode = 2
+layout_mode = 2
+size_flags_horizontal = 4
+size_flags_vertical = 4
+
+[node name="Reprendre" type="Button" parent="Buttons"]
+unique_name_in_owner = true
+layout_mode = 2
+text = "Reprendre"
+
+[node name="RetourEcranTitre" type="Button" parent="Buttons"]
+layout_mode = 2
+text = "Retour écran titre"
+
+[node name="QuitterLeJeu" type="Button" parent="Buttons"]
+layout_mode = 2
+text = "Quitter le jeu"
+
+[connection signal="pressed" from="Buttons/Reprendre" to="." method="_quand_bouton_reprendre_est_presse"]
+[connection signal="pressed" from="Buttons/RetourEcranTitre" to="." method="_quand_bouton_retour_titre_est_presse"]
+[connection signal="pressed" from="Buttons/QuitterLeJeu" to="." method="_quand_bouton_quitter_est_presse"]

二進制
godot/composants/interface/pause/sprite.png


+ 34 - 0
godot/composants/interface/pause/sprite.png.import

@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://bkupreskydgkg"
+path="res://.godot/imported/sprite.png-628168fdfdda7ff734e6e215193162d6.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://composants/interface/pause/sprite.png"
+dest_files=["res://.godot/imported/sprite.png-628168fdfdda7ff734e6e215193162d6.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1

+ 10 - 0
godot/exec/game.tscn

@@ -0,0 +1,10 @@
+[gd_scene load_steps=3 format=3 uid="uid://oem0iyyskwcr"]
+
+[ext_resource type="PackedScene" uid="uid://cyyb8weydthjc" path="res://exec/niveaux/carre_simple.tscn" id="1_q28fi"]
+[ext_resource type="PackedScene" uid="uid://cvsfngjyx7xvw" path="res://composants/interface/pause/pause_menu.tscn" id="2_petgp"]
+
+[node name="Game" type="Node"]
+
+[node name="CarreSimple" parent="." instance=ExtResource("1_q28fi")]
+
+[node name="PauseMenu" parent="." instance=ExtResource("2_petgp")]

+ 6 - 1
godot/project.godot

@@ -12,7 +12,7 @@ config_version=5
 
 config/name="Raquette fracassante"
 config/description="Projet d'apprentissage pour l'atelier Godot des JDLL 2024."
-run/main_scene="res://exec/niveaux/carre_simple.tscn"
+run/main_scene="res://exec/game.tscn"
 config/features=PackedStringArray("4.2", "GL Compatibility")
 config/icon="res://icon.svg"
 
@@ -36,6 +36,11 @@ bouger_a_gauche={
 , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
 ]
 }
+ui_pause={
+"deadzone": 0.5,
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
+]
+}
 
 [rendering]