Use global sounds system in end door

This commit is contained in:
Haze Weathers 2025-03-08 16:33:05 -05:00
parent ba3306c04c
commit af4bece554
3 changed files with 16 additions and 14 deletions

View file

@ -1,18 +1,13 @@
extends Node2D
@export var next_map:PackedScene
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
signal door_entered()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
@export var next_map: PackedScene
func _on_area_2d_body_entered(body: Node2D) -> void:
func _on_player_detector_body_entered(body: Node2D) -> void:
if body is Player:
door_entered.emit()
SceneManager.current_scene = next_map.instantiate()
SceneManager.win_sound.play()

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://bhnse651bcybm"]
[gd_scene load_steps=5 format=3 uid="uid://bhnse651bcybm"]
[ext_resource type="Texture2D" uid="uid://bwq21el575t1g" path="res://assets/textures/door/door.png" id="1_4beu0"]
[ext_resource type="Script" uid="uid://b3ynfi0yyc7t5" path="res://objects/end_door/end_door.gd" id="1_ph88k"]
[ext_resource type="Script" uid="uid://cg3hwyafaokvs" path="res://scripts/global_sound_player/global_sound_player.gd" id="3_8mj78"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qkffx"]
size = Vector2(16, 16)
@ -12,11 +13,18 @@ script = ExtResource("1_ph88k")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_4beu0")
[node name="Area2D" type="Area2D" parent="."]
[node name="PlayerDetector" type="Area2D" parent="."]
collision_mask = 16
monitorable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerDetector"]
shape = SubResource("RectangleShape2D_qkffx")
debug_color = Color(0, 1, 0.701961, 0.419608)
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
[node name="GlobalSoundPlayer" type="Node" parent="."]
script = ExtResource("3_8mj78")
sound = &"WinSound"
metadata/_custom_type_script = "uid://cg3hwyafaokvs"
[connection signal="door_entered" from="." to="GlobalSoundPlayer" method="play"]
[connection signal="body_entered" from="PlayerDetector" to="." method="_on_player_detector_body_entered"]