xiandie/scene/ground/script/general/autoplay_animated_sprite.gd

20 lines
437 B
GDScript

extends AnimatedSprite2D
# from - to
@export var auto_checkout_dict = {}
func _ready() -> void:
if animation:
# 制造一点错差
frame = randi() % sprite_frames.get_frame_count(animation)
play()
animation_finished.connect(_on_animation_finished)
func _on_animation_finished() -> void:
if auto_checkout_dict.has(animation):
var next_animation = auto_checkout_dict[animation]
if next_animation:
play(next_animation)