17 lines
664 B
GDScript3
17 lines
664 B
GDScript3
|
|
class_name SparkleEffect
|
||
|
|
extends RichTextEffect
|
||
|
|
## [sparkle]…[/sparkle]: letters glint gold at random moments, like gems (gold
|
||
|
|
## shows on light and dark cards alike).
|
||
|
|
## [sparkle freq=2.0] sets how often.
|
||
|
|
|
||
|
|
var bbcode := "sparkle"
|
||
|
|
|
||
|
|
|
||
|
|
func _process_custom_fx(char_fx: CharFXTransform) -> bool:
|
||
|
|
var freq := float(char_fx.env.get("freq", 2.0))
|
||
|
|
# Each letter has its own rhythm, so the glints don't line up.
|
||
|
|
var phase := fmod(char_fx.elapsed_time * freq + float(char_fx.relative_index) * 0.618, 1.0)
|
||
|
|
var glint := clampf(1.0 - absf(phase - 0.5) * 8.0, 0.0, 1.0)
|
||
|
|
char_fx.color = char_fx.color.lerp(Color(1.0, 0.78, 0.2, char_fx.color.a), glint * 0.9)
|
||
|
|
return true
|