ajout menu

This commit is contained in:
Mylloon 2021-04-08 02:31:29 +02:00
parent 43f0bed87d
commit 352c043eba
10 changed files with 102 additions and 2 deletions

BIN
assets/images/buttonExit.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/images/buttonExitSelected.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/images/buttonPlay.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/images/buttonPlaySelected.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/images/fondMenu.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/images/titreMenu.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -17,7 +17,7 @@ _global_script_class_icons={
config/name="Tyra" config/name="Tyra"
config/description="Tyra est un jeu 2D." config/description="Tyra est un jeu 2D."
run/main_scene="res://scenes/Monde.tscn" run/main_scene="res://scenes/Menu.tscn"
config/icon="res://assets/images/sortie.png" config/icon="res://assets/images/sortie.png"
config/windows_native_icon="res://assets/images/icon.ico" config/windows_native_icon="res://assets/images/icon.ico"

64
scenes/Menu.tscn Normal file
View file

@ -0,0 +1,64 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/images/fondMenu.png" type="Texture" id=1]
[ext_resource path="res://assets/images/titreMenu.png" type="Texture" id=2]
[ext_resource path="res://assets/images/buttonPlay.png" type="Texture" id=3]
[ext_resource path="res://assets/images/buttonPlaySelected.png" type="Texture" id=4]
[ext_resource path="res://assets/images/buttonExitSelected.png" type="Texture" id=5]
[ext_resource path="res://assets/images/buttonExit.png" type="Texture" id=6]
[ext_resource path="res://scripts/menuPrincipal.gd" type="Script" id=7]
[node name="Menu" type="Node2D"]
[node name="Principal" type="Node2D" parent="."]
script = ExtResource( 7 )
[node name="Sprite" type="Sprite" parent="Principal"]
texture = ExtResource( 1 )
centered = false
[node name="MarginContainer" type="MarginContainer" parent="Principal"]
margin_right = 1024.0
margin_bottom = 600.0
custom_constants/margin_right = 40
custom_constants/margin_top = 40
custom_constants/margin_left = 40
custom_constants/margin_bottom = 40
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="Principal/MarginContainer"]
margin_left = 40.0
margin_top = 40.0
margin_right = 1064.0
margin_bottom = 610.0
size_flags_horizontal = 5
custom_constants/separation = -24
[node name="TextureRect" type="TextureRect" parent="Principal/MarginContainer/VBoxContainer"]
margin_right = 1024.0
margin_bottom = 222.0
texture = ExtResource( 2 )
[node name="VBoxContainer" type="VBoxContainer" parent="Principal/MarginContainer/VBoxContainer"]
margin_left = 350.0
margin_top = 198.0
margin_right = 674.0
margin_bottom = 570.0
size_flags_horizontal = 4
[node name="Jouer" type="TextureButton" parent="Principal/MarginContainer/VBoxContainer/VBoxContainer"]
margin_right = 324.0
margin_bottom = 184.0
texture_normal = ExtResource( 3 )
texture_focused = ExtResource( 4 )
[node name="Quitter" type="TextureButton" parent="Principal/MarginContainer/VBoxContainer/VBoxContainer"]
margin_top = 188.0
margin_right = 324.0
margin_bottom = 372.0
texture_normal = ExtResource( 6 )
texture_focused = ExtResource( 5 )
[connection signal="pressed" from="Principal/MarginContainer/VBoxContainer/VBoxContainer/Jouer" to="Principal" method="_on_Jouer_pressed"]
[connection signal="pressed" from="Principal/MarginContainer/VBoxContainer/VBoxContainer/Quitter" to="Principal" method="_on_Quitter_pressed"]

View file

@ -5,4 +5,5 @@ func _ready():
func _on_Portail_de_fin_body_entered(body): func _on_Portail_de_fin_body_entered(body):
if "Joueur" in body.name: if "Joueur" in body.name:
get_tree().quit() if get_tree().change_scene("res://scenes/Menu.tscn") != OK:
print("Impossible de charger le jeu.")

17
scripts/menuPrincipal.gd Normal file
View file

@ -0,0 +1,17 @@
extends Node2D
func _ready():
$MarginContainer/VBoxContainer/VBoxContainer/Jouer.grab_focus()
func _physics_process(_delta):
if $MarginContainer/VBoxContainer/VBoxContainer/Jouer.is_hovered() == true:
$MarginContainer/VBoxContainer/VBoxContainer/Jouer.grab_focus()
if $MarginContainer/VBoxContainer/VBoxContainer/Quitter.is_hovered() == true:
$MarginContainer/VBoxContainer/VBoxContainer/Quitter.grab_focus()
func _on_Jouer_pressed():
if get_tree().change_scene("res://scenes/Monde1.tscn") != OK:
print("Impossible de charger le jeu.")
func _on_Quitter_pressed():
get_tree().quit()