coin sound
This commit is contained in:
11
coin.gd
11
coin.gd
@@ -1,6 +1,15 @@
|
|||||||
extends Area2D
|
extends Area2D
|
||||||
|
@export var coin_sound: AudioStreamPlayer
|
||||||
|
@export var sprite: AnimatedSprite2D
|
||||||
|
|
||||||
func _on_body_entered(body: Node2D) -> void:
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
print("you got coing")
|
if sprite != null:
|
||||||
|
print("you got coin " + name)
|
||||||
|
coin_sound.play()
|
||||||
|
sprite.queue_free()
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
func _on_coin_sound_finished() -> void:
|
||||||
queue_free()
|
queue_free()
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|||||||
12
coin.tscn
12
coin.tscn
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://csmkrqtuurkyo" path="res://coin.gd" id="1_0t63x"]
|
[ext_resource type="Script" uid="uid://csmkrqtuurkyo" path="res://coin.gd" id="1_0t63x"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c7kuxextst4j0" path="res://sprites/coin/MonedaD.png" id="1_d5gmh"]
|
[ext_resource type="Texture2D" uid="uid://c7kuxextst4j0" path="res://sprites/coin/MonedaD.png" id="1_d5gmh"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://cc8r8h11qeq74" path="res://sounds/chieuk-coin-257878.mp3" id="3_v7riw"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_0t63x"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_0t63x"]
|
||||||
radius = 7.0
|
radius = 7.0
|
||||||
@@ -49,17 +50,24 @@ animations = [{
|
|||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}]
|
}]
|
||||||
|
|
||||||
[node name="Coin" type="Area2D" unique_id=1353750555]
|
[node name="Coin" type="Area2D" unique_id=1353750555 node_paths=PackedStringArray("coin_sound", "sprite")]
|
||||||
|
collision_layer = 2
|
||||||
script = ExtResource("1_0t63x")
|
script = ExtResource("1_0t63x")
|
||||||
|
coin_sound = NodePath("coin_sound")
|
||||||
|
sprite = NodePath("sprite")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1032039025]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1032039025]
|
||||||
scale = Vector2(4, 4)
|
scale = Vector2(4, 4)
|
||||||
shape = SubResource("CircleShape2D_0t63x")
|
shape = SubResource("CircleShape2D_0t63x")
|
||||||
|
|
||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=168181176]
|
[node name="sprite" type="AnimatedSprite2D" parent="." unique_id=168181176]
|
||||||
scale = Vector2(4, 4)
|
scale = Vector2(4, 4)
|
||||||
sprite_frames = SubResource("SpriteFrames_te2np")
|
sprite_frames = SubResource("SpriteFrames_te2np")
|
||||||
autoplay = "default"
|
autoplay = "default"
|
||||||
frame_progress = 0.9891366
|
frame_progress = 0.9891366
|
||||||
|
|
||||||
|
[node name="coin_sound" type="AudioStreamPlayer" parent="." unique_id=2097358849]
|
||||||
|
stream = ExtResource("3_v7riw")
|
||||||
|
|
||||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
[connection signal="finished" from="coin_sound" to="." method="_on_coin_sound_finished"]
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ animations = [{
|
|||||||
size = Vector2(8, 17)
|
size = Vector2(8, 17)
|
||||||
|
|
||||||
[node name="Dino" type="CharacterBody2D" unique_id=1560363456]
|
[node name="Dino" type="CharacterBody2D" unique_id=1560363456]
|
||||||
|
collision_mask = 3
|
||||||
|
|
||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=465878451]
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=465878451]
|
||||||
position = Vector2(0, -9)
|
position = Vector2(0, -9)
|
||||||
|
|||||||
Reference in New Issue
Block a user