From 37e27e3db22c0b33d098a0ac1fb2dfe8861be0fb Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio <fhuya@meta.com> Date: Thu, 17 Aug 2023 07:32:10 -0700 Subject: Add an Android GDExtension plugin sample This sample shows how to integrate gdextension capabilities with Android java/kotlin code by leveraging JNI. --- .../hello_gdextension/src/main/cpp/gdexample.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 plugins/hello_gdextension/src/main/cpp/gdexample.cpp (limited to 'plugins/hello_gdextension/src/main/cpp/gdexample.cpp') diff --git a/plugins/hello_gdextension/src/main/cpp/gdexample.cpp b/plugins/hello_gdextension/src/main/cpp/gdexample.cpp new file mode 100644 index 0000000..1652936 --- /dev/null +++ b/plugins/hello_gdextension/src/main/cpp/gdexample.cpp @@ -0,0 +1,22 @@ +#include "gdexample.h" +#include <godot_cpp/core/class_db.hpp> + +using namespace godot; + +void GDExample::_bind_methods() { + +} + +GDExample::GDExample() { + time_passed = 0.0; +} + +GDExample::~GDExample() {} + +void GDExample::_process(double delta) { + time_passed += delta; + + Vector2 new_position = Vector2(10.0 + (10.0 * sin(time_passed * 2.0)), 10.0 + (10.0 * cos(time_passed * 1.5))); + + set_position(new_position); +} -- cgit v1.2.3