- Edited
I am trying to build a simple text animation, like a type-writer, where characters appear one after the other.
I managed to build something with RichTextEffect:
extends RichTextEffect
class_name RichTextAppear
var bbcode = "appear"
func _process_custom_fx(char_fx):
var speed = char_fx.env.get("speed", 1)
var elapsed_time = char_fx.elapsed_time * speed
var step = 1.0/speed
var index = char_fx.absolute_index
if elapsed_time < index:
char_fx.color.a = 0
elif elapsed_time > index and elapsed_time < index + step:
var animation_delta = elapsed_time - index
char_fx.color.a = animation_delta
else:
char_fx.color.a = 1
return true
Is there a better way to create the text effect? What is causing the massive performance hit? I don't see anything in the code.
I am sure that the RichTextEffect
is causing the problem. A test scene with just the RichTextLabel with this effect is already eating half the CPU time on my machine. (which is a bit older)