Split pause() from AnimationPlayer's stop()
This commit is contained in:
parent
9c02bf1b11
commit
da9396881e
4 changed files with 36 additions and 19 deletions
|
@ -137,6 +137,13 @@
|
||||||
Returns [code]true[/code] if playing an animation.
|
Returns [code]true[/code] if playing an animation.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="pause">
|
||||||
|
<return type="void" />
|
||||||
|
<description>
|
||||||
|
Pauses the currently playing animation. The [member current_animation_position] will be kept and calling [method play] or [method play_backwards] without arguments or with the same animation name as [member assigned_animation] will resume the animation.
|
||||||
|
See also [method stop].
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="play">
|
<method name="play">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="name" type="StringName" default="""" />
|
<param index="0" name="name" type="StringName" default="""" />
|
||||||
|
@ -201,10 +208,9 @@
|
||||||
</method>
|
</method>
|
||||||
<method name="stop">
|
<method name="stop">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="reset" type="bool" default="true" />
|
|
||||||
<description>
|
<description>
|
||||||
Stops or pauses the currently playing animation. If [param reset] is [code]true[/code], the animation position is reset to [code]0[/code] and the playback speed is reset to [code]1.0[/code].
|
Stops the currently playing animation. The animation position is reset to [code]0[/code] and the playback speed is reset to [code]1.0[/code].
|
||||||
If [param reset] is [code]false[/code], the [member current_animation_position] will be kept and calling [method play] or [method play_backwards] without arguments or with the same animation name as [member assigned_animation] will resume the animation.
|
See also [method pause].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
</methods>
|
</methods>
|
||||||
|
|
|
@ -267,7 +267,7 @@ void AnimationPlayerEditor::_stop_pressed() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player->stop(false);
|
player->pause();
|
||||||
play->set_pressed(false);
|
play->set_pressed(false);
|
||||||
stop->set_pressed(true);
|
stop->set_pressed(true);
|
||||||
}
|
}
|
||||||
|
@ -1155,7 +1155,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set, bool
|
||||||
|
|
||||||
player->seek_delta(pos, pos - cpos);
|
player->seek_delta(pos, pos - cpos);
|
||||||
} else {
|
} else {
|
||||||
player->stop(true);
|
player->stop();
|
||||||
player->seek(pos, true);
|
player->seek(pos, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1731,18 +1731,12 @@ String AnimationPlayer::get_assigned_animation() const {
|
||||||
return playback.assigned;
|
return playback.assigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationPlayer::stop(bool p_reset) {
|
void AnimationPlayer::pause() {
|
||||||
_stop_playing_caches();
|
_stop_internal(false);
|
||||||
Playback &c = playback;
|
}
|
||||||
c.blend.clear();
|
|
||||||
if (p_reset) {
|
void AnimationPlayer::stop() {
|
||||||
c.current.from = nullptr;
|
_stop_internal(true);
|
||||||
c.current.speed_scale = 1;
|
|
||||||
c.current.pos = 0;
|
|
||||||
}
|
|
||||||
_set_process(false);
|
|
||||||
queued.clear();
|
|
||||||
playing = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationPlayer::set_speed_scale(float p_speed) {
|
void AnimationPlayer::set_speed_scale(float p_speed) {
|
||||||
|
@ -1957,6 +1951,20 @@ void AnimationPlayer::_set_process(bool p_process, bool p_force) {
|
||||||
processing = p_process;
|
processing = p_process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnimationPlayer::_stop_internal(bool p_reset) {
|
||||||
|
_stop_playing_caches();
|
||||||
|
Playback &c = playback;
|
||||||
|
c.blend.clear();
|
||||||
|
if (p_reset) {
|
||||||
|
c.current.from = nullptr;
|
||||||
|
c.current.speed_scale = 1;
|
||||||
|
c.current.pos = 0;
|
||||||
|
}
|
||||||
|
_set_process(false);
|
||||||
|
queued.clear();
|
||||||
|
playing = false;
|
||||||
|
}
|
||||||
|
|
||||||
void AnimationPlayer::animation_set_next(const StringName &p_animation, const StringName &p_next) {
|
void AnimationPlayer::animation_set_next(const StringName &p_animation, const StringName &p_next) {
|
||||||
ERR_FAIL_COND_MSG(!animation_set.has(p_animation), vformat("Animation not found: %s.", p_animation));
|
ERR_FAIL_COND_MSG(!animation_set.has(p_animation), vformat("Animation not found: %s.", p_animation));
|
||||||
animation_set[p_animation].next = p_next;
|
animation_set[p_animation].next = p_next;
|
||||||
|
@ -2119,7 +2127,8 @@ void AnimationPlayer::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("play", "name", "custom_blend", "custom_speed", "from_end"), &AnimationPlayer::play, DEFVAL(""), DEFVAL(-1), DEFVAL(1.0), DEFVAL(false));
|
ClassDB::bind_method(D_METHOD("play", "name", "custom_blend", "custom_speed", "from_end"), &AnimationPlayer::play, DEFVAL(""), DEFVAL(-1), DEFVAL(1.0), DEFVAL(false));
|
||||||
ClassDB::bind_method(D_METHOD("play_backwards", "name", "custom_blend"), &AnimationPlayer::play_backwards, DEFVAL(""), DEFVAL(-1));
|
ClassDB::bind_method(D_METHOD("play_backwards", "name", "custom_blend"), &AnimationPlayer::play_backwards, DEFVAL(""), DEFVAL(-1));
|
||||||
ClassDB::bind_method(D_METHOD("stop", "reset"), &AnimationPlayer::stop, DEFVAL(true));
|
ClassDB::bind_method(D_METHOD("pause"), &AnimationPlayer::pause);
|
||||||
|
ClassDB::bind_method(D_METHOD("stop"), &AnimationPlayer::stop);
|
||||||
ClassDB::bind_method(D_METHOD("is_playing"), &AnimationPlayer::is_playing);
|
ClassDB::bind_method(D_METHOD("is_playing"), &AnimationPlayer::is_playing);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_current_animation", "anim"), &AnimationPlayer::set_current_animation);
|
ClassDB::bind_method(D_METHOD("set_current_animation", "anim"), &AnimationPlayer::set_current_animation);
|
||||||
|
|
|
@ -294,6 +294,7 @@ private:
|
||||||
void _animation_changed(const StringName &p_name);
|
void _animation_changed(const StringName &p_name);
|
||||||
|
|
||||||
void _set_process(bool p_process, bool p_force = false);
|
void _set_process(bool p_process, bool p_force = false);
|
||||||
|
void _stop_internal(bool p_reset);
|
||||||
|
|
||||||
bool playing = false;
|
bool playing = false;
|
||||||
|
|
||||||
|
@ -346,7 +347,8 @@ public:
|
||||||
void queue(const StringName &p_name);
|
void queue(const StringName &p_name);
|
||||||
Vector<String> get_queue();
|
Vector<String> get_queue();
|
||||||
void clear_queue();
|
void clear_queue();
|
||||||
void stop(bool p_reset = true);
|
void pause();
|
||||||
|
void stop();
|
||||||
bool is_playing() const;
|
bool is_playing() const;
|
||||||
String get_current_animation() const;
|
String get_current_animation() const;
|
||||||
void set_current_animation(const String &p_anim);
|
void set_current_animation(const String &p_anim);
|
||||||
|
|
Loading…
Reference in a new issue