xiandie/scene/effect/dizzy_shader.gd

23 lines
694 B
GDScript3
Raw Normal View History

2025-07-01 17:18:25 +00:00
extends CanvasLayer
@onready var rect = $ColorRect as ColorRect
2025-07-01 18:02:22 +00:00
func _ready() -> void:
rect.material.set("shader_parameter/intensity", 0.0)
2025-07-01 17:18:25 +00:00
2025-07-01 18:02:22 +00:00
var tween: Tween
2025-07-17 08:48:40 +00:00
# duration 最短 1.5s
func dizzy(duration := 3.5, intensity := 1.5, ease_in_duration := 0.5, ease_out_duration := 1.0) -> void:
2025-07-01 17:18:25 +00:00
if tween and tween.is_valid():
tween.kill()
show()
tween = create_tween()
2025-08-14 07:40:33 +00:00
tween.tween_property(rect.material, "shader_parameter/intensity", intensity, ease_in_duration)
2025-07-17 08:48:40 +00:00
tween.tween_interval(maxf(duration - 1.5, 0.01))
2025-08-14 07:40:33 +00:00
tween.tween_property(rect.material, "shader_parameter/intensity", 0.0, ease_out_duration).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC)
2025-07-02 18:29:39 +00:00
tween.finished.connect(hide)