1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-05 19:31:35 +00:00

Fixed awkwardly named AnimatedSprite Setters.

(cherry picked from commit 0c06ed98fb)
This commit is contained in:
Anilforextra
2021-08-04 15:31:40 +05:45
committed by Rémi Verschelde
parent fc7528b366
commit 9351bc4b1c
3 changed files with 10 additions and 21 deletions

View File

@@ -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="String" default="&quot;&quot;" />
@@ -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">

View File

@@ -572,7 +572,7 @@ void AnimatedSprite::_res_changed() {
update();
}
void AnimatedSprite::_set_playing(bool p_playing) {
void AnimatedSprite::set_playing(bool p_playing) {
if (playing == p_playing) {
return;
}
@@ -581,7 +581,7 @@ void AnimatedSprite::_set_playing(bool p_playing) {
set_process_internal(playing);
}
bool AnimatedSprite::_is_playing() const {
bool AnimatedSprite::is_playing() const {
return playing;
}
@@ -595,15 +595,11 @@ void AnimatedSprite::play(const StringName &p_animation, const bool p_backwards)
}
}
_set_playing(true);
set_playing(true);
}
void AnimatedSprite::stop() {
_set_playing(false);
}
bool AnimatedSprite::is_playing() const {
return playing;
set_playing(false);
}
float AnimatedSprite::_get_frame_duration() {
@@ -662,12 +658,11 @@ void AnimatedSprite::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_animation", "animation"), &AnimatedSprite::set_animation);
ClassDB::bind_method(D_METHOD("get_animation"), &AnimatedSprite::get_animation);
ClassDB::bind_method(D_METHOD("_set_playing", "playing"), &AnimatedSprite::_set_playing);
ClassDB::bind_method(D_METHOD("_is_playing"), &AnimatedSprite::_is_playing);
ClassDB::bind_method(D_METHOD("set_playing", "playing"), &AnimatedSprite::set_playing);
ClassDB::bind_method(D_METHOD("is_playing"), &AnimatedSprite::is_playing);
ClassDB::bind_method(D_METHOD("play", "anim", "backwards"), &AnimatedSprite::play, DEFVAL(StringName()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("stop"), &AnimatedSprite::stop);
ClassDB::bind_method(D_METHOD("is_playing"), &AnimatedSprite::is_playing);
ClassDB::bind_method(D_METHOD("set_centered", "centered"), &AnimatedSprite::set_centered);
ClassDB::bind_method(D_METHOD("is_centered"), &AnimatedSprite::is_centered);
@@ -696,7 +691,7 @@ void AnimatedSprite::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation");
ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "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_PROPERTY(PropertyInfo(Variant::BOOL, "centered"), "set_centered", "is_centered");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_h"), "set_flip_h", "is_flipped_h");

View File

@@ -144,8 +144,6 @@ class AnimatedSprite : public Node2D {
float _get_frame_duration();
void _reset_timeout();
void _set_playing(bool p_playing);
bool _is_playing() const;
Rect2 _get_rect() const;
protected:
@@ -172,6 +170,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);