feat: added shorthand listen_to functions to PlayerInput

main
Sara 2024-05-28 16:58:22 +02:00
parent 41f5c440c4
commit 527415677f
2 changed files with 11 additions and 0 deletions

View File

@ -107,6 +107,14 @@ void PlayerInput::listen_to(Listener const& listener) {
this->listeners.push_back(listener);
}
void PlayerInput::listen_to(gd::String action, gd::Callable callable) {
this->listeners.push_back(Listener(action, callable));
}
void PlayerInput::listen_to(gd::String negative, gd::String positive, gd::Callable callable) {
this->listeners.push_back(Listener(negative, positive, callable));
}
void PlayerInput::stop_listening(Node *node) {
for(size_t i = 0; i < this->listeners.size(); ++i) {
Listener l = this->listeners.get(i);

View File

@ -73,6 +73,9 @@ public:
virtual void _process(double deltaTime) override;
void listen_to(Listener const &listener);
void listen_to(gd::String action, gd::Callable callable);
void listen_to(gd::String negative, gd::String positive, gd::Callable callable);
void stop_listening(Node *node);
void stop_listening(Listener const &listener);
void clear_listeners();