瀏覽代碼

:headset: Ajoute un bruit de collison a chaque rebond

de la balle.
DricomDragon 10 月之前
父節點
當前提交
fa1760c084

+ 3 - 0
godot/composants/objets/balle/balle.gd

@@ -2,6 +2,8 @@ class_name Balle
 extends CharacterBody2D
 
 
+signal rebondi
+
 const ratio_diff_angle: float = PI * 0.005 # radian / px
 const ascension_min: float = 10.0 # px / sec
 const vitesse_initiale: float = 100.0 # px / sec
@@ -50,6 +52,7 @@ func en_train_de_monter() -> bool:
 
 func _rebondir(impact: KinematicCollision2D) -> void:
 	_mouvement = _mouvement.bounce(impact.get_normal())
+	rebondi.emit()
 
 
 func _orienter_tir(raquette: Raquette) -> void:

+ 8 - 1
godot/composants/objets/balle/balle.tscn

@@ -1,7 +1,8 @@
-[gd_scene load_steps=4 format=3 uid="uid://vilrv0y5q2re"]
+[gd_scene load_steps=5 format=3 uid="uid://vilrv0y5q2re"]
 
 [ext_resource type="Script" path="res://composants/objets/balle/balle.gd" id="1_n72rw"]
 [ext_resource type="Texture2D" uid="uid://bbpkc5fx4p34l" path="res://composants/objets/balle/ball_main0001.png" id="2_aab72"]
+[ext_resource type="AudioStream" uid="uid://cfmm8vsdh4ahu" path="res://composants/objets/balle/collision_sfx.wav" id="3_7fm42"]
 
 [sub_resource type="CircleShape2D" id="CircleShape2D_lab73"]
 radius = 5.42
@@ -20,3 +21,9 @@ texture = ExtResource("2_aab72")
 
 [node name="Forme" type="CollisionShape2D" parent="."]
 shape = SubResource("CircleShape2D_lab73")
+
+[node name="CollisionNoise" type="AudioStreamPlayer2D" parent="."]
+stream = ExtResource("3_7fm42")
+bus = &"Bruits"
+
+[connection signal="rebondi" from="." to="CollisionNoise" method="play"]

godot/effets/eclatement_brique/collision_sfx.wav → godot/composants/objets/balle/collision_sfx.wav


+ 3 - 3
godot/effets/eclatement_brique/collision_sfx.wav.import

@@ -3,12 +3,12 @@
 importer="wav"
 type="AudioStreamWAV"
 uid="uid://cfmm8vsdh4ahu"
-path="res://.godot/imported/collision_sfx.wav-5ec16d5f5185b3d4c32aef34819af9f8.sample"
+path="res://.godot/imported/collision_sfx.wav-f7926b7f033001637468571d51b0d90d.sample"
 
 [deps]
 
-source_file="res://effets/eclatement_brique/collision_sfx.wav"
-dest_files=["res://.godot/imported/collision_sfx.wav-5ec16d5f5185b3d4c32aef34819af9f8.sample"]
+source_file="res://composants/objets/balle/collision_sfx.wav"
+dest_files=["res://.godot/imported/collision_sfx.wav-f7926b7f033001637468571d51b0d90d.sample"]
 
 [params]