0 votes

Greetings!
I am trying to replicate This Singleton Example using c++ with GDNative, but i haven't been able to find out how to do this part

var s = ResourceLoader.load(path)

# Instance the new scene.
current_scene = s.instance()

# Add it to the active scene, as child of root.
get_tree().get_root().add_child(current_scene)

Any help would be greatly appreciated.
Thank you.

asked May 14 in Engine by SergLoff (28 points)
edited May 17 by SergLoff

1 Answer

0 votes
Best answer

A reddit user gave me the solution so in case somebody ever needs it I'm going to post it here.

CurrentScene->free();
ResourceLoader* reLo = ResourceLoader::get_singleton();
Ref<PackedScene> res = reLo->load(path);
CurrentScene = res->instance();

get_tree()->get_root()->add_child(CurrentScene);
get_tree()->set_current_scene(CurrentScene);

Cheers!

answered May 17 by SergLoff (28 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.