extends Sprite

signal complete


func _ready() -> void:
    # Fade in
    if not $Tween.interpolate_property(self, 'self_modulate:a', 0, 1, 3, Tween.TRANS_LINEAR, Tween.EASE_IN):
        print('ERROR: Splash Screen fade in animation has errors.')
    if not $Tween.start():
        print('ERROR: Splash Screen fade in animation failed to start.')

    yield($Tween, 'tween_completed')  # Wait for fade in to complete

    # Fade out
    if not $Tween.interpolate_property(self, 'self_modulate:a', 1, 0, 3, Tween.TRANS_LINEAR, Tween.EASE_OUT, 2):
        print('ERROR: Splash Screen fade out animation has errors.')
    if not $Tween.start():
        print('ERROR: Splash Screen fade out animation failed to start.')

    yield($Tween, 'tween_completed')  # Wait for fade out to complete
    emit_signal('complete')
    return


func _input(event: InputEvent) -> void:
    if event.is_action_pressed('ui_accept'):
        emit_signal('complete')
    return
