Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | hidemat |
I have Example
class that inherits from Reference
, and this is the _register_methods()
method:
void Example::_register_methods()
{
// register other methods including open()
register_signal<Example>((char*)"opened");
}
Then within my code I call the emit_signal
method:
void Example::open()
{
run_other_code();
emit_signal("opened");
}
Then in GDscript I initilize my class and call the open method:
func _ready()"
var example = Example.new()
example.open()
yield(example, "opened")
#some other code
EDIT: I was able to connect to the signal like this:
example.connect("open", self, "_on_Example_open")
So I guess there is a problem with calling the yield keyword this way?
Not sure what your overall goal is, but this seems like a weird use case for a signal.
Signals are for communicating between nodes/scenes that don’t really own each other but need to occasionally communicate anyway; in this case you are trying to make an object locally, have that object send a signal, then catch that signal right after that when you could do the same thing by just calling the method on that local variable.
Again, not sure what your goals are but I would not worry about this specific issue unless the use case really warrants it
w411-3 | 2022-03-09 02:31
Hello I need your help.
I don’t understand.
I want to send a signal in C++ and get it in GDNative to play an animation.
Do you think you can help me ?
Rem | 2022-12-16 10:50
You’ll need to be a whole lot more specific for anyone here to help you. All I can say immediately is it sounds like a weird design that would lead you to want to send a signal between C++ modules and GDNative just to play an animation.
Keep thinking on it and do ask your own new question if you think someone can help; just make sure you give enough detail
w411-3 | 2022-12-17 02:28