Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | CosmoXD |
Hi, I’m having a issue when i use GDNative (C++) with my game, When i press the “run” button appears the Godot logo but then the application closes, I checked my code many times but i cannot find the error.
Note: My build configuration is Debug and x64.
This is my code:
lib.cpp:
#include "Common.h"
#include "Player.h"
using namespace godot;
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options * o)
{
Godot::gdnative_init(o);
}
extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options * o)
{
Godot::gdnative_terminate(o);
}
extern "C" void GDN_EXPORT godot_nativescript_init(void* handle)
{
Godot::nativescript_init(handle);
register_class<godot::Player>();
}
Common.h:
include <Godot.hpp>
using namespace godot;
Player.h:
#pragma once
#include <KinematicBody2D.hpp>
#include "Common.h"
namespace godot
{
class Player : public KinematicBody2D
{
GODOT_CLASS(Player, KinematicBody2D);
public:
static void _register_methods();
void _ready();
void _process(float delta);
Player();
~Player();
};
}
Player.cpp:
#include "Player.h"
namespace godot
{
Player::Player()
{
}
Player::~Player()
{
}
void Player::_register_methods()
{
register_method("_ready", &Player::_ready);
register_method("_process", &Player::_process);
}
void Player::_ready()
{
Godot::print("Hello, World!");
}
void Player::_process(float delta)
{
}
}