diff options
author | Anilforextra <anilforextra@gmail.com> | 2021-08-04 15:31:40 +0545 |
---|---|---|
committer | Anilforextra <anilforextra@gmail.com> | 2021-08-04 15:31:40 +0545 |
commit | 0c06ed98fb1e4c9e0aaaaef7ddab38ed952a996a (patch) | |
tree | b57f22ee6bd4d68f53edb2b9d475ff8add841be3 | |
parent | 1eff610e2bd71521db6d0f4fee25a641e1c7bdd6 (diff) |
Fixed awkwardly named AnimatedSprite Setters.
-rw-r--r-- | doc/classes/AnimatedSprite2D.xml | 8 | ||||
-rw-r--r-- | scene/2d/animated_sprite_2d.cpp | 19 | ||||
-rw-r--r-- | scene/2d/animated_sprite_2d.h | 4 |
3 files changed, 10 insertions, 21 deletions
diff --git a/doc/classes/AnimatedSprite2D.xml b/doc/classes/AnimatedSprite2D.xml index 14e19b4c9a..953492857b 100644 --- a/doc/classes/AnimatedSprite2D.xml +++ b/doc/classes/AnimatedSprite2D.xml @@ -12,12 +12,6 @@ <link title="2D Dodge The Creeps Demo">https://godotengine.org/asset-library/asset/515</link> </tutorials> <methods> - <method name="is_playing" qualifiers="const"> - <return type="bool" /> - <description> - Returns [code]true[/code] if an animation is currently being played. - </description> - </method> <method name="play"> <return type="void" /> <argument index="0" name="anim" type="StringName" default="&""" /> @@ -55,7 +49,7 @@ <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)"> The texture's drawing offset. </member> - <member name="playing" type="bool" setter="_set_playing" getter="_is_playing" default="false"> + <member name="playing" type="bool" setter="set_playing" getter="is_playing" default="false"> If [code]true[/code], the [member animation] is currently playing. </member> <member name="speed_scale" type="float" setter="set_speed_scale" getter="get_speed_scale" default="1.0"> diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index da2ab6ada8..395b4e5ca0 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -368,7 +368,7 @@ void AnimatedSprite2D::_res_changed() { update(); } -void AnimatedSprite2D::_set_playing(bool p_playing) { +void AnimatedSprite2D::set_playing(bool p_playing) { if (playing == p_playing) { return; } @@ -377,7 +377,7 @@ void AnimatedSprite2D::_set_playing(bool p_playing) { set_process_internal(playing); } -bool AnimatedSprite2D::_is_playing() const { +bool AnimatedSprite2D::is_playing() const { return playing; } @@ -391,15 +391,11 @@ void AnimatedSprite2D::play(const StringName &p_animation, const bool p_backward } } - _set_playing(true); + set_playing(true); } void AnimatedSprite2D::stop() { - _set_playing(false); -} - -bool AnimatedSprite2D::is_playing() const { - return playing; + set_playing(false); } float AnimatedSprite2D::_get_frame_duration() { @@ -457,12 +453,11 @@ void AnimatedSprite2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_animation", "animation"), &AnimatedSprite2D::set_animation); ClassDB::bind_method(D_METHOD("get_animation"), &AnimatedSprite2D::get_animation); - ClassDB::bind_method(D_METHOD("_set_playing", "playing"), &AnimatedSprite2D::_set_playing); - ClassDB::bind_method(D_METHOD("_is_playing"), &AnimatedSprite2D::_is_playing); + ClassDB::bind_method(D_METHOD("set_playing", "playing"), &AnimatedSprite2D::set_playing); + ClassDB::bind_method(D_METHOD("is_playing"), &AnimatedSprite2D::is_playing); ClassDB::bind_method(D_METHOD("play", "anim", "backwards"), &AnimatedSprite2D::play, DEFVAL(StringName()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("stop"), &AnimatedSprite2D::stop); - ClassDB::bind_method(D_METHOD("is_playing"), &AnimatedSprite2D::is_playing); ClassDB::bind_method(D_METHOD("set_centered", "centered"), &AnimatedSprite2D::set_centered); ClassDB::bind_method(D_METHOD("is_centered"), &AnimatedSprite2D::is_centered); @@ -490,7 +485,7 @@ void AnimatedSprite2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "animation"), "set_animation", "get_animation"); ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "speed_scale"), "set_speed_scale", "get_speed_scale"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "_set_playing", "_is_playing"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "set_playing", "is_playing"); ADD_GROUP("Offset", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "centered"), "set_centered", "is_centered"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); diff --git a/scene/2d/animated_sprite_2d.h b/scene/2d/animated_sprite_2d.h index ef0027edf1..7163b9bb64 100644 --- a/scene/2d/animated_sprite_2d.h +++ b/scene/2d/animated_sprite_2d.h @@ -58,8 +58,6 @@ class AnimatedSprite2D : public Node2D { float _get_frame_duration(); void _reset_timeout(); - void _set_playing(bool p_playing); - bool _is_playing() const; Rect2 _get_rect() const; protected: @@ -86,6 +84,8 @@ public: void play(const StringName &p_animation = StringName(), const bool p_backwards = false); void stop(); + + void set_playing(bool p_playing); bool is_playing() const; void set_animation(const StringName &p_animation); |