summaryrefslogtreecommitdiffstats
path: root/scene/main/node.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2021-06-20 00:35:28 +0200
committerGitHub <noreply@github.com>2021-06-20 00:35:28 +0200
commit9c182b0f45df0f1a134f047899cdd9291c34f58a (patch)
tree6735c004f29713e1dde829ee03f7373c6b1e8db8 /scene/main/node.cpp
parentbbf6d645fb324ce73cb3a0141dc508a83f66bd00 (diff)
parent900b2e0fdcc12d28a744ae36004b9b2dc7f196d1 (diff)
downloadredot-engine-9c182b0f45df0f1a134f047899cdd9291c34f58a.tar.gz
Merge pull request #41794 from KoBeWi/shiny_new_tweens
Diffstat (limited to 'scene/main/node.cpp')
-rw-r--r--scene/main/node.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index e1abea81ef..679fca0217 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -35,6 +35,7 @@
#include "core/object/message_queue.h"
#include "core/string/print_string.h"
#include "instance_placeholder.h"
+#include "scene/animation/tween.h"
#include "scene/debugger/scene_debugger.h"
#include "scene/resources/packed_scene.h"
#include "scene/scene_string_names.h"
@@ -1686,6 +1687,13 @@ int Node::get_index() const {
return data.pos;
}
+Ref<Tween> Node::create_tween() {
+ ERR_FAIL_COND_V_MSG(!data.tree, nullptr, "Can't create Tween when not inside scene tree.");
+ Ref<Tween> tween = get_tree()->create_tween();
+ tween->bind_node(this);
+ return tween;
+}
+
void Node::remove_and_skip() {
ERR_FAIL_COND(!data.parent);
@@ -2555,6 +2563,7 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_physics_processing_internal"), &Node::is_physics_processing_internal);
ClassDB::bind_method(D_METHOD("get_tree"), &Node::get_tree);
+ ClassDB::bind_method(D_METHOD("create_tween"), &Node::create_tween);
ClassDB::bind_method(D_METHOD("duplicate", "flags"), &Node::duplicate, DEFVAL(DUPLICATE_USE_INSTANCING | DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS));
ClassDB::bind_method(D_METHOD("replace_by", "node", "keep_groups"), &Node::replace_by, DEFVAL(false));