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

Add animation_finished signal and fix frame_changed signal for AnimatedSprite3D

Fixes #40301.
Fixes #45947.

(cherry picked from commit c3be0c2c04)
This commit is contained in:
Jitesh
2020-07-12 05:39:21 -07:00
committed by Rémi Verschelde
parent 972e7bd27c
commit d968a03cbc
2 changed files with 8 additions and 0 deletions

View File

@@ -49,6 +49,11 @@
</member>
</members>
<signals>
<signal name="animation_finished">
<description>
Emitted when the animation is finished (when it plays the last frame). If the animation is looping, this signal is emitted every time the last frame is drawn.
</description>
</signal>
<signal name="frame_changed">
<description>
Emitted when [member frame] changed.

View File

@@ -1047,12 +1047,14 @@ void AnimatedSprite3D::_notification(int p_what) {
} else {
frame = fc - 1;
}
emit_signal(SceneStringNames::get_singleton()->animation_finished);
} else {
frame++;
}
_queue_update();
_change_notify("frame");
emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
float to_process = MIN(timeout, remaining);
@@ -1246,6 +1248,7 @@ void AnimatedSprite3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("_res_changed"), &AnimatedSprite3D::_res_changed);
ADD_SIGNAL(MethodInfo("frame_changed"));
ADD_SIGNAL(MethodInfo("animation_finished"));
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");