![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | lutein |
How can I write a custom signal?
Here is source code.
class Root : public Node2D {
GODOT_CLASS(Root, Node2D)
public:
signal my_signal; //I can't see a signal type in c++ file..
static void _register_methods();
void _init();
void _ready();
Root();
~Root();
};
Problem is solved.
I found a method in Object class.
add_user_signal(“signal_name”).
There is no need to declare signal type variable.
So I just put them in the _ready function and connect to target node like this.
void godot::Player::_ready() {
add_user_signal("my_signal");
connect("my_signal", get_node("target_node_path"), "target_node_function_name");
}
lutein | 2019-06-02 09:30