ajout game over

This commit is contained in:
Mylloon 2021-04-08 13:25:25 +02:00
parent e941fbda3d
commit 11c80ef24c
5 changed files with 40 additions and 1 deletions

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

Binary file not shown.

BIN
assets/sounds/mort.wav (Stored with Git LFS) Normal file

Binary file not shown.

21
scenes/GameOver.tscn Normal file
View file

@ -0,0 +1,21 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/images/gameOver.png" type="Texture" id=1]
[ext_resource path="res://scripts/GameOver.gd" type="Script" id=2]
[ext_resource path="res://assets/sounds/mort.wav" type="AudioStream" id=3]
[node name="GameOver" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
centered = false
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 3 )
autoplay = true

12
scripts/GameOver.gd Normal file
View file

@ -0,0 +1,12 @@
extends Control
func _ready():
var timer = Timer.new()
timer.connect("timeout", self, "_on_timer_timeout")
timer.set_wait_time(2) # 2 secondes
add_child(timer) # Ajout un timer
timer.start() # Lance le timer
func _on_timer_timeout():
if get_tree().change_scene("res://scenes/Menu.tscn") != OK: # recommence au début
print("Une erreur est survenue lors du rechargement de la scène.") # gestion erreur

View file

@ -33,7 +33,7 @@ func tir():
get_tree().get_root().call_deferred("add_child", objectBalle) # ajout de la balle
func mort():
if get_tree().change_scene("res://scenes/Menu.tscn") != OK: # reccomence au début
if get_tree().change_scene("res://scenes/GameOver.tscn") != OK: # écran game over
print("Une erreur est survenue lors du rechargement de la scène.") # gestion erreur
func _on_Area2D_body_entered(body):