Use global sounds system in end door
This commit is contained in:
parent
ba3306c04c
commit
af4bece554
3 changed files with 16 additions and 14 deletions
|
@ -28,7 +28,6 @@ enum ScaleMode {
|
||||||
ProjectSettings.get_setting("display/window/size/viewport_height")
|
ProjectSettings.get_setting("display/window/size/viewport_height")
|
||||||
)
|
)
|
||||||
|
|
||||||
@onready var win_sound = $WinSound
|
|
||||||
|
|
||||||
## The currently active scene.
|
## The currently active scene.
|
||||||
##
|
##
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
@export var next_map:PackedScene
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
signal door_entered()
|
||||||
func _ready() -> void:
|
|
||||||
pass # Replace with function body.
|
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
@export var next_map: PackedScene
|
||||||
func _process(delta: float) -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _on_area_2d_body_entered(body: Node2D) -> void:
|
func _on_player_detector_body_entered(body: Node2D) -> void:
|
||||||
if body is Player:
|
if body is Player:
|
||||||
|
door_entered.emit()
|
||||||
SceneManager.current_scene = next_map.instantiate()
|
SceneManager.current_scene = next_map.instantiate()
|
||||||
SceneManager.win_sound.play()
|
|
||||||
|
|
|
@ -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="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://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"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qkffx"]
|
||||||
size = Vector2(16, 16)
|
size = Vector2(16, 16)
|
||||||
|
@ -12,11 +13,18 @@ script = ExtResource("1_ph88k")
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
texture = ExtResource("1_4beu0")
|
texture = ExtResource("1_4beu0")
|
||||||
|
|
||||||
[node name="Area2D" type="Area2D" parent="."]
|
[node name="PlayerDetector" type="Area2D" parent="."]
|
||||||
collision_mask = 16
|
collision_mask = 16
|
||||||
|
monitorable = false
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerDetector"]
|
||||||
shape = SubResource("RectangleShape2D_qkffx")
|
shape = SubResource("RectangleShape2D_qkffx")
|
||||||
debug_color = Color(0, 1, 0.701961, 0.419608)
|
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"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue