mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 12:12:28 +00:00
Fix AnimationSprite2D/3D::play using wrong end_frame
On playing a different animation to the current backwards will start the new animation on the last animations last frame not the new ones
This commit is contained in:
parent
95110ddcb4
commit
dc6e664fda
@ -473,9 +473,10 @@ void AnimatedSprite2D::play(const StringName &p_name, float p_custom_scale, bool
|
|||||||
playing = true;
|
playing = true;
|
||||||
custom_speed_scale = p_custom_scale;
|
custom_speed_scale = p_custom_scale;
|
||||||
|
|
||||||
int end_frame = MAX(0, frames->get_frame_count(animation) - 1);
|
|
||||||
if (name != animation) {
|
if (name != animation) {
|
||||||
animation = name;
|
animation = name;
|
||||||
|
int end_frame = MAX(0, frames->get_frame_count(animation) - 1);
|
||||||
|
|
||||||
if (p_from_end) {
|
if (p_from_end) {
|
||||||
set_frame_and_progress(end_frame, 1.0);
|
set_frame_and_progress(end_frame, 1.0);
|
||||||
} else {
|
} else {
|
||||||
@ -483,7 +484,9 @@ void AnimatedSprite2D::play(const StringName &p_name, float p_custom_scale, bool
|
|||||||
}
|
}
|
||||||
emit_signal(SceneStringName(animation_changed));
|
emit_signal(SceneStringName(animation_changed));
|
||||||
} else {
|
} else {
|
||||||
|
int end_frame = MAX(0, frames->get_frame_count(animation) - 1);
|
||||||
bool is_backward = signbit(speed_scale * custom_speed_scale);
|
bool is_backward = signbit(speed_scale * custom_speed_scale);
|
||||||
|
|
||||||
if (p_from_end && is_backward && frame == 0 && frame_progress <= 0.0) {
|
if (p_from_end && is_backward && frame == 0 && frame_progress <= 0.0) {
|
||||||
set_frame_and_progress(end_frame, 1.0);
|
set_frame_and_progress(end_frame, 1.0);
|
||||||
} else if (!p_from_end && !is_backward && frame == end_frame && frame_progress >= 1.0) {
|
} else if (!p_from_end && !is_backward && frame == end_frame && frame_progress >= 1.0) {
|
||||||
|
@ -1334,9 +1334,10 @@ void AnimatedSprite3D::play(const StringName &p_name, float p_custom_scale, bool
|
|||||||
playing = true;
|
playing = true;
|
||||||
custom_speed_scale = p_custom_scale;
|
custom_speed_scale = p_custom_scale;
|
||||||
|
|
||||||
int end_frame = MAX(0, frames->get_frame_count(animation) - 1);
|
|
||||||
if (name != animation) {
|
if (name != animation) {
|
||||||
animation = name;
|
animation = name;
|
||||||
|
int end_frame = MAX(0, frames->get_frame_count(animation) - 1);
|
||||||
|
|
||||||
if (p_from_end) {
|
if (p_from_end) {
|
||||||
set_frame_and_progress(end_frame, 1.0);
|
set_frame_and_progress(end_frame, 1.0);
|
||||||
} else {
|
} else {
|
||||||
@ -1344,7 +1345,9 @@ void AnimatedSprite3D::play(const StringName &p_name, float p_custom_scale, bool
|
|||||||
}
|
}
|
||||||
emit_signal(SceneStringName(animation_changed));
|
emit_signal(SceneStringName(animation_changed));
|
||||||
} else {
|
} else {
|
||||||
|
int end_frame = MAX(0, frames->get_frame_count(animation) - 1);
|
||||||
bool is_backward = signbit(speed_scale * custom_speed_scale);
|
bool is_backward = signbit(speed_scale * custom_speed_scale);
|
||||||
|
|
||||||
if (p_from_end && is_backward && frame == 0 && frame_progress <= 0.0) {
|
if (p_from_end && is_backward && frame == 0 && frame_progress <= 0.0) {
|
||||||
set_frame_and_progress(end_frame, 1.0);
|
set_frame_and_progress(end_frame, 1.0);
|
||||||
} else if (!p_from_end && !is_backward && frame == end_frame && frame_progress >= 1.0) {
|
} else if (!p_from_end && !is_backward && frame == end_frame && frame_progress >= 1.0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user