Merge pull request #64157 from Mickeon/remove-mysterious-is-playing

This commit is contained in:
Rémi Verschelde 2022-09-01 17:40:32 +02:00 committed by GitHub
commit ca59f47f31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 21 deletions

View File

@ -10,12 +10,6 @@
<link title="2D Sprite animation (also applies to 3D)">$DOCS_URL/tutorials/2d/2d_sprite_animation.html</link> <link title="2D Sprite animation (also applies to 3D)">$DOCS_URL/tutorials/2d/2d_sprite_animation.html</link>
</tutorials> </tutorials>
<methods> <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"> <method name="play">
<return type="void" /> <return type="void" />
<param index="0" name="anim" type="StringName" default="&amp;&quot;&quot;" /> <param index="0" name="anim" type="StringName" default="&amp;&quot;&quot;" />
@ -40,7 +34,7 @@
<member name="frames" type="SpriteFrames" setter="set_sprite_frames" getter="get_sprite_frames"> <member name="frames" type="SpriteFrames" setter="set_sprite_frames" getter="get_sprite_frames">
The [SpriteFrames] resource containing the animation(s). The [SpriteFrames] resource containing the animation(s).
</member> </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. If [code]true[/code], the [member animation] is currently playing.
</member> </member>
</members> </members>

View File

@ -1174,7 +1174,7 @@ void AnimatedSprite3D::_res_changed() {
_queue_update(); _queue_update();
} }
void AnimatedSprite3D::_set_playing(bool p_playing) { void AnimatedSprite3D::set_playing(bool p_playing) {
if (playing == p_playing) { if (playing == p_playing) {
return; return;
} }
@ -1183,7 +1183,7 @@ void AnimatedSprite3D::_set_playing(bool p_playing) {
set_process_internal(playing); set_process_internal(playing);
} }
bool AnimatedSprite3D::_is_playing() const { bool AnimatedSprite3D::is_playing() const {
return playing; return playing;
} }
@ -1191,15 +1191,11 @@ void AnimatedSprite3D::play(const StringName &p_animation) {
if (p_animation) { if (p_animation) {
set_animation(p_animation); set_animation(p_animation);
} }
_set_playing(true); set_playing(true);
} }
void AnimatedSprite3D::stop() { void AnimatedSprite3D::stop() {
_set_playing(false); set_playing(false);
}
bool AnimatedSprite3D::is_playing() const {
return playing;
} }
void AnimatedSprite3D::_reset_timeout() { void AnimatedSprite3D::_reset_timeout() {
@ -1262,12 +1258,11 @@ void AnimatedSprite3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_animation", "animation"), &AnimatedSprite3D::set_animation); ClassDB::bind_method(D_METHOD("set_animation", "animation"), &AnimatedSprite3D::set_animation);
ClassDB::bind_method(D_METHOD("get_animation"), &AnimatedSprite3D::get_animation); ClassDB::bind_method(D_METHOD("get_animation"), &AnimatedSprite3D::get_animation);
ClassDB::bind_method(D_METHOD("_set_playing", "playing"), &AnimatedSprite3D::_set_playing); ClassDB::bind_method(D_METHOD("set_playing", "playing"), &AnimatedSprite3D::set_playing);
ClassDB::bind_method(D_METHOD("_is_playing"), &AnimatedSprite3D::_is_playing); ClassDB::bind_method(D_METHOD("is_playing"), &AnimatedSprite3D::is_playing);
ClassDB::bind_method(D_METHOD("play", "anim"), &AnimatedSprite3D::play, DEFVAL(StringName())); ClassDB::bind_method(D_METHOD("play", "anim"), &AnimatedSprite3D::play, DEFVAL(StringName()));
ClassDB::bind_method(D_METHOD("stop"), &AnimatedSprite3D::stop); ClassDB::bind_method(D_METHOD("stop"), &AnimatedSprite3D::stop);
ClassDB::bind_method(D_METHOD("is_playing"), &AnimatedSprite3D::is_playing);
ClassDB::bind_method(D_METHOD("set_frame", "frame"), &AnimatedSprite3D::set_frame); ClassDB::bind_method(D_METHOD("set_frame", "frame"), &AnimatedSprite3D::set_frame);
ClassDB::bind_method(D_METHOD("get_frame"), &AnimatedSprite3D::get_frame); ClassDB::bind_method(D_METHOD("get_frame"), &AnimatedSprite3D::get_frame);
@ -1280,7 +1275,7 @@ void AnimatedSprite3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE, "SpriteFrames"), "set_sprite_frames", "get_sprite_frames"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE, "SpriteFrames"), "set_sprite_frames", "get_sprite_frames");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation");
ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame"); ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "_set_playing", "_is_playing"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "set_playing", "is_playing");
} }
AnimatedSprite3D::AnimatedSprite3D() { AnimatedSprite3D::AnimatedSprite3D() {

View File

@ -219,8 +219,6 @@ class AnimatedSprite3D : public SpriteBase3D {
void _res_changed(); void _res_changed();
void _reset_timeout(); void _reset_timeout();
void _set_playing(bool p_playing);
bool _is_playing() const;
RID last_shader; RID last_shader;
RID last_texture; RID last_texture;
@ -237,6 +235,8 @@ public:
void play(const StringName &p_animation = StringName()); void play(const StringName &p_animation = StringName());
void stop(); void stop();
void set_playing(bool p_playing);
bool is_playing() const; bool is_playing() const;
void set_animation(const StringName &p_animation); void set_animation(const StringName &p_animation);