Add the 'finished' signal to AnimatedSprite
This commit is contained in:
parent
c7bc44d5ad
commit
f6262fde11
2 changed files with 9 additions and 0 deletions
|
@ -2519,6 +2519,11 @@
|
||||||
Emitted when frame is changed.
|
Emitted when frame is changed.
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</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>
|
</signals>
|
||||||
<constants>
|
<constants>
|
||||||
</constants>
|
</constants>
|
||||||
|
|
|
@ -362,6 +362,9 @@ void AnimatedSprite::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
frame++;
|
frame++;
|
||||||
|
if (frame==fc-1) {
|
||||||
|
emit_signal(SceneStringNames::get_singleton()->finished);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
@ -696,6 +699,7 @@ void AnimatedSprite::_bind_methods() {
|
||||||
ObjectTypeDB::bind_method(_MD("_res_changed"),&AnimatedSprite::_res_changed);
|
ObjectTypeDB::bind_method(_MD("_res_changed"),&AnimatedSprite::_res_changed);
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("frame_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_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"));
|
ADD_PROPERTY( PropertyInfo( Variant::STRING, "animation"), _SCS("set_animation"),_SCS("get_animation"));
|
||||||
|
|
Loading…
Reference in a new issue