diff options
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/node_2d.cpp | 22 | ||||
-rw-r--r-- | scene/2d/node_2d.h | 4 |
2 files changed, 26 insertions, 0 deletions
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 4788a1b813..166bc26848 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -149,6 +149,10 @@ void Node2D::set_rotation(real_t p_radians) { _update_transform(); } +void Node2D::set_rotation_degrees(real_t p_degrees) { + set_rotation(Math::deg_to_rad(p_degrees)); +} + void Node2D::set_skew(real_t p_radians) { if (_xform_dirty) { const_cast<Node2D *>(this)->_update_xform_values(); @@ -187,6 +191,10 @@ real_t Node2D::get_rotation() const { return rotation; } +real_t Node2D::get_rotation_degrees() const { + return Math::rad_to_deg(get_rotation()); +} + real_t Node2D::get_skew() const { if (_xform_dirty) { const_cast<Node2D *>(this)->_update_xform_values(); @@ -259,6 +267,10 @@ real_t Node2D::get_global_rotation() const { return get_global_transform().get_rotation(); } +real_t Node2D::get_global_rotation_degrees() const { + return Math::rad_to_deg(get_global_rotation()); +} + real_t Node2D::get_global_skew() const { return get_global_transform().get_skew(); } @@ -276,6 +288,10 @@ void Node2D::set_global_rotation(const real_t p_radians) { } } +void Node2D::set_global_rotation_degrees(const real_t p_degrees) { + set_global_rotation(Math::deg_to_rad(p_degrees)); +} + void Node2D::set_global_skew(const real_t p_radians) { CanvasItem *parent = get_parent_item(); if (parent) { @@ -372,11 +388,13 @@ void Node2D::_notification(int p_notification) { void Node2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Node2D::set_rotation_degrees); ClassDB::bind_method(D_METHOD("set_skew", "radians"), &Node2D::set_skew); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Node2D::set_scale); ClassDB::bind_method(D_METHOD("get_position"), &Node2D::get_position); ClassDB::bind_method(D_METHOD("get_rotation"), &Node2D::get_rotation); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Node2D::get_rotation_degrees); ClassDB::bind_method(D_METHOD("get_skew"), &Node2D::get_skew); ClassDB::bind_method(D_METHOD("get_scale"), &Node2D::get_scale); @@ -390,7 +408,9 @@ void Node2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_global_position", "position"), &Node2D::set_global_position); ClassDB::bind_method(D_METHOD("get_global_position"), &Node2D::get_global_position); ClassDB::bind_method(D_METHOD("set_global_rotation", "radians"), &Node2D::set_global_rotation); + ClassDB::bind_method(D_METHOD("set_global_rotation_degrees", "degrees"), &Node2D::set_global_rotation_degrees); ClassDB::bind_method(D_METHOD("get_global_rotation"), &Node2D::get_global_rotation); + ClassDB::bind_method(D_METHOD("get_global_rotation_degrees"), &Node2D::get_global_rotation_degrees); ClassDB::bind_method(D_METHOD("set_global_skew", "radians"), &Node2D::set_global_skew); ClassDB::bind_method(D_METHOD("get_global_skew"), &Node2D::get_global_skew); ClassDB::bind_method(D_METHOD("set_global_scale", "scale"), &Node2D::set_global_scale); @@ -410,12 +430,14 @@ void Node2D::_bind_methods() { ADD_GROUP("Transform", ""); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position", PROPERTY_HINT_RANGE, "-99999,99999,0.001,or_less,or_greater,hide_slider,suffix:px"), "set_position", "get_position"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians"), "set_rotation", "get_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale", PROPERTY_HINT_LINK), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "skew", PROPERTY_HINT_RANGE, "-89.9,89.9,0.1,radians"), "set_skew", "get_skew"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "set_transform", "get_transform"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "set_global_position", "get_global_position"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation", PROPERTY_HINT_NONE, "radians", PROPERTY_USAGE_NONE), "set_global_rotation", "get_global_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_rotation_degrees", "get_global_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_scale", "get_global_scale"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_skew", PROPERTY_HINT_NONE, "radians", PROPERTY_USAGE_NONE), "set_global_skew", "get_global_skew"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "set_global_transform", "get_global_transform"); diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index 76707dc422..b066332dcb 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -73,6 +73,7 @@ public: void set_position(const Point2 &p_pos); void set_rotation(real_t p_radians); + void set_rotation_degrees(real_t p_degrees); void set_skew(real_t p_radians); void set_scale(const Size2 &p_scale); @@ -85,11 +86,13 @@ public: Point2 get_position() const; real_t get_rotation() const; + real_t get_rotation_degrees() const; real_t get_skew() const; Size2 get_scale() const; Point2 get_global_position() const; real_t get_global_rotation() const; + real_t get_global_rotation_degrees() const; real_t get_global_skew() const; Size2 get_global_scale() const; @@ -97,6 +100,7 @@ public: void set_global_transform(const Transform2D &p_transform); void set_global_position(const Point2 &p_pos); void set_global_rotation(const real_t p_radians); + void set_global_rotation_degrees(const real_t p_degrees); void set_global_skew(const real_t p_radians); void set_global_scale(const Size2 &p_scale); |