Add sound effect to cannon 1-3

This commit is contained in:
Moe Poi ~ 2023-10-21 22:45:51 +07:00
parent 9ab2105242
commit 1374ee3bb3
6 changed files with 37 additions and 5 deletions

BIN
assets/audio/cannon.mp3 Normal file

Binary file not shown.

View file

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://bx4oba7yo6duu"
path="res://.godot/imported/cannon.mp3-518b9fd6fe08132381dbe692630b67d0.mp3str"
[deps]
source_file="res://assets/audio/cannon.mp3"
dest_files=["res://.godot/imported/cannon.mp3-518b9fd6fe08132381dbe692630b67d0.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=13 format=3 uid="uid://bexddlltacp6k"]
[gd_scene load_steps=14 format=3 uid="uid://bexddlltacp6k"]
[ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_decej"]
[ext_resource type="AudioStream" uid="uid://bx4oba7yo6duu" path="res://assets/audio/cannon.mp3" id="3_h4ljg"]
[ext_resource type="Texture2D" uid="uid://2ovf2ymtftgo" path="res://assets/spritesheets/towers/cannon-1.png" id="3_q7708"]
[sub_resource type="AtlasTexture" id="AtlasTexture_3x0a2"]
@ -99,5 +100,9 @@ rotation = 1.5708
scale = Vector2(0.3, 0.3)
show_percentage = false
[node name="Shoot" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_h4ljg")
volume_db = -40.0
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
[connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"]

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=14 format=3 uid="uid://dij57511gfg4t"]
[ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_eyei4"]
[ext_resource type="PackedScene" uid="uid://dqa80ptcc8p70" path="res://scenes/bullets/bullet_1.tscn" id="2_r6s38"]
[ext_resource type="AudioStream" uid="uid://bx4oba7yo6duu" path="res://assets/audio/cannon.mp3" id="3_cih6o"]
[ext_resource type="Texture2D" uid="uid://br7wgq61n6ufv" path="res://assets/spritesheets/towers/cannon-2.png" id="3_us71t"]
[sub_resource type="AtlasTexture" id="AtlasTexture_74asi"]
@ -73,7 +73,6 @@ radius = 138.293
[node name="cannon-2" type="Node2D" groups=["Towers"]]
script = ExtResource("1_eyei4")
bullet = ExtResource("2_r6s38")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
position = Vector2(-1, 0)
@ -100,5 +99,9 @@ rotation = 1.5708
scale = Vector2(0.3, 0.3)
show_percentage = false
[node name="Shoot" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_cih6o")
volume_db = -40.0
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
[connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"]

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=14 format=3 uid="uid://mxre00inxhlf"]
[ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_pa8xy"]
[ext_resource type="PackedScene" uid="uid://dqa80ptcc8p70" path="res://scenes/bullets/bullet_1.tscn" id="2_gqu6e"]
[ext_resource type="AudioStream" uid="uid://bx4oba7yo6duu" path="res://assets/audio/cannon.mp3" id="3_r4bfa"]
[ext_resource type="Texture2D" uid="uid://by4hjrjfcxsdl" path="res://assets/spritesheets/towers/cannon-3.png" id="3_tjfbt"]
[sub_resource type="AtlasTexture" id="AtlasTexture_roben"]
@ -73,7 +73,6 @@ radius = 138.293
[node name="cannon-3" type="Node2D" groups=["Towers"]]
script = ExtResource("1_pa8xy")
bullet = ExtResource("2_gqu6e")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
position = Vector2(-1, 0)
@ -100,5 +99,9 @@ rotation = 1.5708
scale = Vector2(0.3, 0.3)
show_percentage = false
[node name="Shoot" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_r4bfa")
volume_db = -40.0
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
[connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"]

View file

@ -4,6 +4,7 @@ signal on_destroy(tower_placement_id)
@onready var rayCast = $RayCast2D
@onready var timer = $Timer
@onready var shoot = $Shoot
var bullet: PackedScene = null
@ -58,6 +59,7 @@ func _physics_process(_delta):
func _shoot():
if bullet:
shoot.play()
var bullet_instance: Node2D = bullet.instantiate()
bullet_instance.dir = rotation
bullet_instance.rotation = rotation