ajout son à la mort d'un ennemi

This commit is contained in:
Mylloon 2021-04-08 13:55:24 +02:00
parent 5233c96855
commit 65a1a1c9ae
5 changed files with 19 additions and 2 deletions

View file

@ -1,4 +1,5 @@
background -> https://tinyurl.com/yjfwbf2e
mort -> https://tinyurl.com/yzl6lem6
menuPrincipal -> https://tinyurl.com/yfophdqk
balle -> https://tinyurl.com/yfsuwngs
balle -> https://tinyurl.com/yfsuwngs
mortEnnemi -> https://tinyurl.com/ydj8utsd

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

Binary file not shown.

View file

@ -16,7 +16,7 @@ shape = SubResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
[node name="SonBalle" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource( 3 )
volume_db = -28.0
pitch_scale = 1.85

View file

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://assets/sounds/mortEnnemi.wav" type="AudioStream" id=1]
[node name="MortEnnemi" type="AudioStreamPlayer2D"]
stream = ExtResource( 1 )
volume_db = -29.0
autoplay = true

View file

@ -2,6 +2,8 @@ extends Area2D
var vitesseBalle = 700
var sonMortEnnemi = preload("res://scenes/SonMortEnnemi.tscn") # récupération Son
func _ready():
pass
@ -13,4 +15,7 @@ func _on_Area2D_body_entered(body):
queue_free()
if "Ennemi" in body.name: # supprime l'ennemi et la balle quand le joueur touche qq1
queue_free()
var son = sonMortEnnemi.instance() # création object son
son.position = get_global_position() # récupération de la position
get_tree().get_root().call_deferred("add_child", son) # ajout du son
body.queue_free()