0 votes

I want to know how to create an instance with GDNative C++ I got no idea how to do it.

asked May 7 in Engine by KramchayDig (50 points)

An instance of what? A node instance? A scene instance? Do you know how to do it in GDScript to begin with? (I would recommend doing so before rushing C++ and GDNative)

yes I want to create a node instance and add it in as a child from a parent.

1 Answer

+1 vote

In GDScript:

# Creates a Sprite node and adds it as child of the node
# the current script is attached on
var node = Sprite.new()

In C++:

// I believe `new Sprite()` would not work, for reasons I don't remember
Sprite *node = Sprite::_new();
answered May 8 by Zylann (26,139 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.