make the restart button send the game started event
This commit is contained in:
parent
e29492447d
commit
5d611f790d
@ -1,4 +1,5 @@
|
|||||||
#include "gui/game_over/GameOverScreen.h"
|
#include "gui/game_over/GameOverScreen.h"
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
|
||||||
#include <PackedScene.hpp>
|
#include <PackedScene.hpp>
|
||||||
@ -11,6 +12,7 @@ void alai::GameOverScreen::_register_methods()
|
|||||||
{
|
{
|
||||||
godot::register_method("_on_restart_button_pressed", &GameOverScreen::_on_restart_button_pressed);
|
godot::register_method("_on_restart_button_pressed", &GameOverScreen::_on_restart_button_pressed);
|
||||||
godot::register_method("_ready", &GameOverScreen::_ready);
|
godot::register_method("_ready", &GameOverScreen::_ready);
|
||||||
|
godot::register_method("restart_game", &GameOverScreen::restart_game);
|
||||||
godot::register_method("connect_signal", &GameOverScreen::connect_signal);
|
godot::register_method("connect_signal", &GameOverScreen::connect_signal);
|
||||||
godot::register_method("_on_player_died", &GameOverScreen::_on_player_died);
|
godot::register_method("_on_player_died", &GameOverScreen::_on_player_died);
|
||||||
}
|
}
|
||||||
@ -45,7 +47,7 @@ void alai::GameOverScreen::_on_restart_button_pressed()
|
|||||||
{
|
{
|
||||||
level_node->add_child(level);
|
level_node->add_child(level);
|
||||||
set_visible(false);
|
set_visible(false);
|
||||||
call_deferred("connect_signal");
|
call_deferred("restart_game");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -79,6 +81,13 @@ void alai::GameOverScreen::_on_player_died()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void alai::GameOverScreen::restart_game()
|
||||||
|
{
|
||||||
|
auto event = get_node<alai::Event>("/root/Event");
|
||||||
|
event->emit_signal("game_started");
|
||||||
|
connect_signal();
|
||||||
|
}
|
||||||
|
|
||||||
void alai::GameOverScreen::connect_signal()
|
void alai::GameOverScreen::connect_signal()
|
||||||
{
|
{
|
||||||
auto event = get_node<alai::Event>("/root/Event");
|
auto event = get_node<alai::Event>("/root/Event");
|
||||||
|
@ -52,6 +52,7 @@ namespace alai
|
|||||||
void _ready();
|
void _ready();
|
||||||
void _on_player_died();
|
void _on_player_died();
|
||||||
void _on_restart_button_pressed();
|
void _on_restart_button_pressed();
|
||||||
|
void restart_game();
|
||||||
void connect_signal();
|
void connect_signal();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user