32 lines
735 B
GDScript
32 lines
735 B
GDScript
@tool
|
|
class_name IncantationText
|
|
extends Control
|
|
|
|
@export_multiline var text: String:
|
|
set(new_value):
|
|
text = new_value
|
|
queue_redraw()
|
|
@export var colored_offset: float = 0:
|
|
set(new_value):
|
|
colored_offset = new_value
|
|
queue_redraw()
|
|
|
|
var curve: Curve2D
|
|
|
|
func _ready():
|
|
curve = (get_parent() as Path2D).curve
|
|
|
|
func _draw():
|
|
if text.length() < 2: return
|
|
|
|
var offset = 0
|
|
for c in text:
|
|
var t = curve.sample_baked_with_rotation(offset)
|
|
draw_set_transform(t.origin - (Vector2.UP * 5).rotated(t.get_rotation()), t.get_rotation())
|
|
draw_char(get_theme_default_font(), Vector2.ZERO, c, 16, Color.WHITE if offset >= colored_offset else Color.RED)
|
|
offset += 10
|
|
|
|
|
|
func _on_visibility_changed():
|
|
print("Test")
|
|
queue_redraw()
|