From c3be0c2c041656bf18aa7aef51a9bf671f0fbd21 Mon Sep 17 00:00:00 2001 From: Jitesh Date: Sun, 12 Jul 2020 05:39:21 -0700 Subject: Add animation_finished signal and fix frame_changed signal for AnimatedSprite3D Fixes #40301. Fixes #45947. --- doc/classes/AnimatedSprite3D.xml | 5 +++++ scene/3d/sprite_3d.cpp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/doc/classes/AnimatedSprite3D.xml b/doc/classes/AnimatedSprite3D.xml index e1fb78e5b5..02ccab4e05 100644 --- a/doc/classes/AnimatedSprite3D.xml +++ b/doc/classes/AnimatedSprite3D.xml @@ -49,6 +49,11 @@ + + + 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. + + Emitted when [member frame] changed. diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index c26224d0e3..cb2df9130f 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -888,11 +888,13 @@ void AnimatedSprite3D::_notification(int p_what) { } else { frame = fc - 1; } + emit_signal(SceneStringNames::get_singleton()->animation_finished); } else { frame++; } _queue_update(); + emit_signal(SceneStringNames::get_singleton()->frame_changed); } float to_process = MIN(timeout, remaining); @@ -1082,6 +1084,7 @@ void AnimatedSprite3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_frame"), &AnimatedSprite3D::get_frame); 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_NAME, "animation"), "set_animation", "get_animation"); -- cgit v1.2.3