feat: added shorthand listen_to functions to PlayerInput
parent
41f5c440c4
commit
527415677f
|
@ -107,6 +107,14 @@ void PlayerInput::listen_to(Listener const& listener) {
|
||||||
this->listeners.push_back(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) {
|
void PlayerInput::stop_listening(Node *node) {
|
||||||
for(size_t i = 0; i < this->listeners.size(); ++i) {
|
for(size_t i = 0; i < this->listeners.size(); ++i) {
|
||||||
Listener l = this->listeners.get(i);
|
Listener l = this->listeners.get(i);
|
||||||
|
|
|
@ -73,6 +73,9 @@ public:
|
||||||
virtual void _process(double deltaTime) override;
|
virtual void _process(double deltaTime) override;
|
||||||
|
|
||||||
void listen_to(Listener const &listener);
|
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(Node *node);
|
||||||
void stop_listening(Listener const &listener);
|
void stop_listening(Listener const &listener);
|
||||||
void clear_listeners();
|
void clear_listeners();
|
||||||
|
|
Loading…
Reference in New Issue