diff options
author | Wilhem Barbier <nounoursheureux@openmailbox.org> | 2017-01-02 12:24:37 +0100 |
---|---|---|
committer | Wilhem Barbier <nounoursheureux@openmailbox.org> | 2017-01-02 12:24:37 +0100 |
commit | f6262fde11cac8b7d1a3d299042c1af6b321cf24 (patch) | |
tree | 02fa393edc26ab3e72f1ae1cbbff12842c1665bd | |
parent | c7bc44d5ad9aae4902280012f7654e2318cd910e (diff) |
Add the 'finished' signal to AnimatedSprite
-rw-r--r-- | doc/base/classes.xml | 5 | ||||
-rw-r--r-- | scene/2d/animated_sprite.cpp | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 234ef04be5..82f54d16b8 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -2519,6 +2519,11 @@ Emitted when frame is changed. </description> </signal> + <signal name="finished"> + <description> + Emitted when the animation is finished (when it plays the last frame). If the animation is looping, this signal is emitted everytime the last frame is drawn, before looping. + </description> + </signal> </signals> <constants> </constants> diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 5a50939579..2ead6b2c96 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -362,6 +362,9 @@ void AnimatedSprite::_notification(int p_what) { } } else { frame++; + if (frame==fc-1) { + emit_signal(SceneStringNames::get_singleton()->finished); + } } update(); @@ -696,6 +699,7 @@ void AnimatedSprite::_bind_methods() { ObjectTypeDB::bind_method(_MD("_res_changed"),&AnimatedSprite::_res_changed); ADD_SIGNAL(MethodInfo("frame_changed")); + ADD_SIGNAL(MethodInfo("finished")); ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "frames",PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames")); ADD_PROPERTY( PropertyInfo( Variant::STRING, "animation"), _SCS("set_animation"),_SCS("get_animation")); |