From 1b13dfdd3768c172c7c0abe644383df14de12fb6 Mon Sep 17 00:00:00 2001 From: Henrique Alves Date: Sat, 24 Sep 2022 22:00:50 -0300 Subject: Add CRTCanvasLayer scene --- addons/crt_shader/CRTShader.gd | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 addons/crt_shader/CRTShader.gd (limited to 'addons/crt_shader/CRTShader.gd') diff --git a/addons/crt_shader/CRTShader.gd b/addons/crt_shader/CRTShader.gd new file mode 100644 index 0000000..464b275 --- /dev/null +++ b/addons/crt_shader/CRTShader.gd @@ -0,0 +1,23 @@ +extends ColorRect + +onready var glitch_loop = false +onready var fun = null + +func _ready(): + $GlitchAnimation.connect("animation_finished", self, "_on_animation_finished") + +func _on_animation_finished(anim): + if anim == "Glitch" and glitch_loop: + $GlitchAnimation.play("GlitchLoop") + +func start_glitch_loop(): + $GlitchAnimation.play("GlitchLoop") + glitch_loop = true + +func tween(fun : FuncRef, force = false): + if not force and $GlitchAnimation.is_playing() and $GlitchAnimation.current_animation == "Glitch": return + $GlitchAnimation.play("Glitch") + self.fun = fun + +func call_funcref(): + if fun: fun.call_func() -- cgit v1.2.3