add singleton example
parent
0d8de3f426
commit
1815783acd
@ -1,28 +0,0 @@
|
|||||||
#include "example.hpp"
|
|
||||||
|
|
||||||
#include <godot_cpp/core/class_db.hpp>
|
|
||||||
|
|
||||||
#include <godot_cpp/classes/global_constants.hpp>
|
|
||||||
#include <godot_cpp/classes/label.hpp>
|
|
||||||
#include <godot_cpp/variant/utility_functions.hpp>
|
|
||||||
|
|
||||||
using namespace godot;
|
|
||||||
|
|
||||||
void Example::_bind_methods()
|
|
||||||
{
|
|
||||||
// TODO: Static https://github.com/godotengine/godot/issues/61963
|
|
||||||
ClassDB::bind_method(D_METHOD("hello_extension"), &Example::hello_extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
Example::Example()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Example::~Example()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Example::hello_extension()
|
|
||||||
{
|
|
||||||
UtilityFunctions::print("Hello GDExtension!");
|
|
||||||
}
|
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
#include "my_node.hpp"
|
||||||
|
|
||||||
|
#include <godot_cpp/core/class_db.hpp>
|
||||||
|
|
||||||
|
#include <godot_cpp/classes/global_constants.hpp>
|
||||||
|
#include <godot_cpp/classes/label.hpp>
|
||||||
|
#include <godot_cpp/variant/utility_functions.hpp>
|
||||||
|
|
||||||
|
using namespace godot;
|
||||||
|
|
||||||
|
void MyNode::_bind_methods()
|
||||||
|
{
|
||||||
|
ClassDB::bind_method(D_METHOD("hello_node"), &MyNode::hello_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
MyNode::MyNode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MyNode::~MyNode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyNode::hello_node()
|
||||||
|
{
|
||||||
|
UtilityFunctions::print("Hello Node!");
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
#include "my_singleton.hpp"
|
||||||
|
|
||||||
|
#include <godot_cpp/core/class_db.hpp>
|
||||||
|
|
||||||
|
#include <godot_cpp/classes/global_constants.hpp>
|
||||||
|
#include <godot_cpp/classes/label.hpp>
|
||||||
|
#include <godot_cpp/variant/utility_functions.hpp>
|
||||||
|
|
||||||
|
using namespace godot;
|
||||||
|
|
||||||
|
void MySingleton::_bind_methods()
|
||||||
|
{
|
||||||
|
ClassDB::bind_method(D_METHOD("hello_singleton"), &MySingleton::hello_singleton);
|
||||||
|
}
|
||||||
|
|
||||||
|
MySingleton::MySingleton()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MySingleton::~MySingleton()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySingleton::hello_singleton()
|
||||||
|
{
|
||||||
|
UtilityFunctions::print("Hello Singleton!");
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <godot_cpp/classes/object.hpp>
|
||||||
|
#include <godot_cpp/classes/global_constants.hpp>
|
||||||
|
#include <godot_cpp/classes/viewport.hpp>
|
||||||
|
|
||||||
|
#include <godot_cpp/core/binder_common.hpp>
|
||||||
|
|
||||||
|
using namespace godot;
|
||||||
|
|
||||||
|
class MySingleton : public Object
|
||||||
|
{
|
||||||
|
GDCLASS(MySingleton, Object);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void _bind_methods();
|
||||||
|
|
||||||
|
public:
|
||||||
|
MySingleton();
|
||||||
|
~MySingleton();
|
||||||
|
|
||||||
|
void hello_singleton();
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue