summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/node_2d.cpp8
-rw-r--r--scene/2d/node_2d.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 0b7cdafdef..1c0efe773f 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -133,6 +133,14 @@ void Node2D::_update_transform() {
_notify_transform();
}
+void Node2D::reparent(Node *p_parent, bool p_keep_global_transform) {
+ Transform2D temp = get_global_transform();
+ Node::reparent(p_parent);
+ if (p_keep_global_transform) {
+ set_global_transform(temp);
+ }
+}
+
void Node2D::set_position(const Point2 &p_pos) {
if (_xform_dirty) {
const_cast<Node2D *>(this)->_update_xform_values();
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index e332745da5..119e23cd98 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -70,6 +70,7 @@ public:
virtual void _edit_set_rect(const Rect2 &p_edit_rect) override;
#endif
+ virtual void reparent(Node *p_parent, bool p_keep_global_transform = true) override;
void set_position(const Point2 &p_pos);
void set_rotation(real_t p_radians);