feature/music #48

Merged
Martin merged 5 commits from feature/music into develop 2022-09-01 23:25:14 -04:00
3 changed files with 23 additions and 1 deletions
Showing only changes of commit e7a1b4f2f8 - Show all commits

View File

@ -1,8 +1,9 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/fonts/ttf/PixelOperator8.ttf" type="DynamicFontData" id=1] [ext_resource path="res://assets/fonts/ttf/PixelOperator8.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://assets/fonts/ttf/PixelOperatorHB8.ttf" type="DynamicFontData" id=2] [ext_resource path="res://assets/fonts/ttf/PixelOperatorHB8.ttf" type="DynamicFontData" id=2]
[ext_resource path="res://gui/GameWonScreen.gdns" type="Script" id=3] [ext_resource path="res://gui/GameWonScreen.gdns" type="Script" id=3]
[ext_resource path="res://assets/sounds/victory.wav" type="AudioStream" id=4]
[sub_resource type="DynamicFont" id=1] [sub_resource type="DynamicFont" id=1]
size = 50 size = 50
@ -45,4 +46,9 @@ custom_fonts/font = SubResource( 2 )
custom_styles/hover = SubResource( 3 ) custom_styles/hover = SubResource( 3 )
text = "SALIR" text = "SALIR"
[node name="VictorySound" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 4 )
volume_db = -18.0
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[connection signal="pressed" from="Control/QuitButton" to="." method="_on_quit_button_pressed"] [connection signal="pressed" from="Control/QuitButton" to="." method="_on_quit_button_pressed"]

View File

@ -2,6 +2,7 @@
#include "Event.h" #include "Event.h"
#include <AudioStreamPlayer.hpp>
#include <SceneTree.hpp> #include <SceneTree.hpp>
#include <Viewport.hpp> #include <Viewport.hpp>
@ -11,6 +12,7 @@ void alai::GameWonScreen::_register_methods()
godot::register_method("connect_signal", &GameWonScreen::connect_signal); godot::register_method("connect_signal", &GameWonScreen::connect_signal);
godot::register_method("_on_player_won", &GameWonScreen::_on_player_won); godot::register_method("_on_player_won", &GameWonScreen::_on_player_won);
godot::register_method("_on_quit_button_pressed", &GameWonScreen::_on_quit_button_pressed); godot::register_method("_on_quit_button_pressed", &GameWonScreen::_on_quit_button_pressed);
godot::register_method("_on_visibility_changed", &GameWonScreen::_on_visibility_changed);
} }
alai::GameWonScreen::GameWonScreen() alai::GameWonScreen::GameWonScreen()
@ -64,3 +66,16 @@ void alai::GameWonScreen::connect_signal()
auto event = get_node<alai::Event>("/root/Event"); auto event = get_node<alai::Event>("/root/Event");
event->connect("player_won", this, "_on_player_won"); event->connect("player_won", this, "_on_player_won");
} }
void alai::GameWonScreen::_on_visibility_changed()
{
auto victorysound = get_node<godot::AudioStreamPlayer>("VictorySound");
if (is_visible())
{
victorysound->play();
}
else
{
victorysound->stop();
}
}

View File

@ -45,6 +45,7 @@ namespace alai
void _on_player_won(); void _on_player_won();
void _on_quit_button_pressed(); void _on_quit_button_pressed();
void connect_signal(); void connect_signal();
void _on_visibility_changed();
}; };
} }