22 lines
568 B
GDScript
22 lines
568 B
GDScript
extends Sprite2D
|
|
|
|
@export var fade_duration: float = 0.5
|
|
var tween: Tween
|
|
|
|
func _ready():
|
|
# Start with outline invisible
|
|
material.set_shader_parameter("outline_alpha", 0.0)
|
|
start_continuous_fade()
|
|
|
|
func start_continuous_fade():
|
|
tween = create_tween()
|
|
tween.set_loops() # Makes it loop infinitely
|
|
tween.tween_method(set_outline_alpha, 0.0, 1.0, fade_duration)
|
|
tween.tween_method(set_outline_alpha, 1.0, 0.0, fade_duration)
|
|
|
|
func set_outline_alpha(value: float):
|
|
material.set_shader_parameter("outline_alpha", value)
|
|
|
|
func stop_fade():
|
|
if tween:
|
|
tween.kill()
|