Skip to content

Commit 72cf639

Browse files
committed
Merge pull request #111178 from PhairZ/anim-is-paused
Expose `is_valid()` from `AnimationPlayer` to make detecting paused animations possible.
2 parents 91ad968 + 2cb1c51 commit 72cf639

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

doc/classes/AnimationPlayer.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@
9393
Returns [code]true[/code] if an animation is currently playing with a section.
9494
</description>
9595
</method>
96+
<method name="is_animation_active" qualifiers="const">
97+
<return type="bool" />
98+
<description>
99+
Returns [code]true[/code] if the an animation is currently active. An animation is active if it was played by calling [method play] and was not finished yet, or was stopped by calling [method stop].
100+
This can be used to check whether an animation is currently paused or stopped.
101+
[codeblock]
102+
var is_paused = not is_playing() and is_animation_active()
103+
var is_stopped = not is_playing() and not is_animation_active()
104+
[/codeblock]
105+
</description>
106+
</method>
96107
<method name="is_playing" qualifiers="const">
97108
<return type="bool" />
98109
<description>

scene/animation/animation_player.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@ void AnimationPlayer::_bind_methods() {
977977
ClassDB::bind_method(D_METHOD("pause"), &AnimationPlayer::pause);
978978
ClassDB::bind_method(D_METHOD("stop", "keep_state"), &AnimationPlayer::stop, DEFVAL(false));
979979
ClassDB::bind_method(D_METHOD("is_playing"), &AnimationPlayer::is_playing);
980+
ClassDB::bind_method(D_METHOD("is_animation_active"), &AnimationPlayer::is_valid);
980981

981982
ClassDB::bind_method(D_METHOD("set_current_animation", "animation"), &AnimationPlayer::set_current_animation);
982983
ClassDB::bind_method(D_METHOD("get_current_animation"), &AnimationPlayer::get_current_animation);

0 commit comments

Comments
 (0)