Question #1
When instancing scenes from a c++ native script, what is the lifetime of the object returned by the pointer?
auto loader = godot::ResourceLoader::get_singleton();
godot::Ref<godot::PackedScene> myScene =
loader->load("res://assets/MyScene.tscn", "PackedScene");
if (myScene.is_valid()) {
Node* node = myScene->instance();
addChild(node);
//Do i have to "delete node;" in my C++ NativeScript class destructor?
//Should I free it with Node::queue_free()?
}
Question #2
Lets say I have a C++ NativeScript class something like:
class MyClass : public godot::Sprite {
GODOT_CLASS(MyClass, godot::Sprite);
public:
static void _register_methods();
void _init();
void _ready();
void _process(float delta);
};
I want MyClass objects to be able to receive signals. As an example, lets say I want to receive the CollisionObject2D's signal for input event which has the following "signature" in the Godot editor:
input_event(Node viewport, InputEvent event, int shape_idx)
To do so I need to add a function to MyClass (and register it), but what should the signature for MyClass::handle_input_event
be?
void handle_input_event(???)
void handle_input_event(Node* n, InputEvent* ev, int s_idx)?
void handle_input_event(Node& n, InputEvent& ev, int s_idx)?
void handle_input_event(Variant& n, Variant& ev, int s_idx)?
//etc?
Is there a standard conversion for signal signatures to c++ types?