-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://be6f0odpenf2d"] | ||
[gd_scene load_steps=3 format=3 uid="uid://be6f0odpenf2d"] | ||
|
||
[ext_resource type="Script" path="res://scripts/main.gd" id="1_c2d3a"] | ||
[ext_resource type="Script" path="res://scripts/test.gd" id="2_ccrxe"] | ||
|
||
[node name="Main" type="Main"] | ||
script = ExtResource("1_c2d3a") | ||
|
||
[node name="Test" type="Test" parent="."] | ||
script = ExtResource("2_ccrxe") | ||
|
||
[connection signal="custom_signal_example" from="." to="." method="_on_custom_signal_example"] | ||
[connection signal="custom_signal_example" from="Test" to="Test" method="_on_test_custom_signal_example"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extends Test | ||
|
||
func _on_test_custom_signal_example(delta_time): | ||
print("DeltaTime value sent from C++ to TEST::GDScript: ", delta_time) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include <godot_cpp/classes/node.hpp> | ||
|
||
#include "util/engine.hpp" | ||
|
||
namespace rl | ||
{ | ||
class Test : public godot::Node | ||
{ | ||
GDCLASS(Test, godot::Node); | ||
|
||
public: | ||
Test() = default; | ||
|
||
void _physics_process(double delta) override | ||
{ | ||
if (engine::editor_active()) | ||
return; | ||
|
||
m_signal_timer += delta; | ||
if (m_signal_timer > 1.0) | ||
{ | ||
this->emit_signal(event::signal_example, delta); | ||
m_signal_timer -= 1.0; | ||
} | ||
} | ||
|
||
protected: | ||
static void _bind_methods() | ||
{ | ||
signal_binding<Test, event::signal_example>::add<double>(); | ||
} | ||
|
||
private: | ||
double m_signal_timer{ 0.0 }; | ||
}; | ||
} |