|
|
|
|
Reply From: |
Yuminous |
Sort of.
There is a BB Code text effect fade
which will smoothly fade the alpha of your text, but it isnβt animated.
Itβs possible to animate this with scripting (by replacing the bbcode with the start
value incremented from a negative value like -10
) and this would be fairly easy to do β but it is only rendered left-to-right and canβt fade the text from start-to-finish like you were wanting.
Itβs still possible to do that with RichTextEffects but you would need to create a custom RichTextEffect. You can see the docs page for some more information on that: BBCode in RichTextLabel β Godot Engine (stable) documentation in English
It is quite a jump in complexity from using the existing bbcode, but once you have it coded you can simply type it like any other text [effect][/effect]
.
Edited Solution:
This example just uses the default fade
bbcode with a script to animate the text.
var counter = -20
if text_animation == true:
counter += 1
if counter < 161:
$RichTextLabel.set_bbcode("[fade start=" + str(counter) + " length=10]" + $RichTextLabel.text + "[/fade]")
To animate the fade-out transition from start-to-finish a 2nd RichTextLabel comprised of black squares βββ and the same colour as the first labelβs background is animated in exactly the same way but with the start βcounterβ value offset.
else:
$RichTextLabel2.set_bbcode("[fade start=" + str(counter-180) + " length=10]" + "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ" + "[/fade]")
Thanks! Yeah, thatβs what I was looking at, but the custom RichTextEffects seem very complicated by comparison to write, and Iβm having trouble figuring out where to begin with this
elvisish | 2021-07-10 08:45
Unfortunately I canβt help you out on that front because Iβve never wrote one myself.
How important is the fading from start-to-finish? Another option is that you could fade it out by modulating the entire RichTextLabel.
Yuminous | 2021-07-10 09:05
Thanks, Iβve been looking through for some ideas! The fade thatβs built-in might work, but I want it per letter successively, rather than as a full block (there was an example on github that did it as a full block fade and it didnβt look quite right).
elvisish | 2021-07-10 09:27
Moved image to OP
Yuminous | 2021-07-10 09:41
Here you go. An example using only fade
. It uses a second RichTextLabel of block characters β
with the same colour as the background.
Yuminous | 2021-07-10 11:41
This is useful, but the code above is not the full code. it is inside a function I guess? Doesnβt seem to be working for me so Iβm guessing thereβs something else there Iβm missing?
robotscanplay | 2021-09-12 15:02
Yes, itβs reliant on a continuous looping function β _process
or _physics_process
.
So, in this case you should try:
var counter = -20
func _physics_process(delta):
if text_animation == true:
counter += 1
if counter < 161:
$RichTextLabel.set_bbcode("[fade start=" + str(counter) + " length=10]" + $RichTextLabel.text + "[/fade]")
else:
$RichTextLabel2.set_bbcode("[fade start=" + str(counter-180) + " length=10]" + "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ" + "[/fade]")
But⦠I should say the functioning of this code is as hacky as it looks. It may not look right unless you have a font with the required characters.
I do remember with this question I was actually halfway to coding a special RichTextEffect that would be automatic and reversible, but never got around to finishing it.
Do you want to achieve this kind of reversible effect in your project too?
Yuminous | 2021-09-13 10:50