Last active
October 26, 2017 07:28
-
-
Save RameshRavone/4b06a23303482127577a9f4707005e75 to your computer and use it in GitHub Desktop.
GDNative Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <core/Godot.hpp> | |
| #include <Reference.hpp> | |
| using namespace godot; | |
| class SimpleClass : public GodotScript<Reference> { | |
| GODOT_CLASS(SimpleClass); | |
| public: | |
| SimpleClass() { } | |
| void test_void_method() { | |
| Godot::print("This is test"); | |
| } | |
| Variant method(Variant arg) { | |
| Variant ret; | |
| ret = arg; | |
| return ret; | |
| } | |
| static void _register_methods() { | |
| register_method("method", &SimpleClass::method); | |
| /** | |
| * How to register exports like gdscript | |
| * export var _name = "SimpleClass" | |
| **/ | |
| register_property((char *)"base/name", &SimpleClass::_name, String("SimpleClass")); | |
| /** For registering signal **/ | |
| register_signal<SimpleClass>("signal_name"); | |
| } | |
| String _name; | |
| }; | |
| /** GDNative Initialize **/ | |
| GDNATIVE_INIT(godot_gdnative_init_options *options) { | |
| } | |
| /** GDNative Terminate **/ | |
| GDNATIVE_TERMINATE(godot_gdnative_terminate_options *options) { | |
| } | |
| /** NativeScript Initialize **/ | |
| NATIVESCRIPT_INIT() { | |
| register_class<SimpleClass>(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment