This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

Happy new year everyone,

I managed to bbcode-tweak my RichTextLabel so that the first digit turns blue when a certain number of digits are entered:

var templateWriting = "[right][color=blue]{firstDigit}[/color]{remainingDigits}[/right]"

I can also make, for example, that first digit shake...

"[right][shake rate=15 level=20]{firstDigit}[/shake]{remainingDigits}[/right]"

This all works fine. But I can't have both effects at the same time. I thought that should work like this:

"[right][color=blue][shake rate=15 level=20]{firstDigit}[/color][/shake]{remainingDigits}[/right]"

But this doesn't seem to work. How could I achieve this?

LIKE THIS: [color] [shake] need to close in the right order [/shake] [/color]. Careful not to mix them up.

However, what my question is aiming for in the first place: how can I have that first digit to be set a little higher than the others? I was wondering if that could be done via "offset", maybe something like [offset = Vector2 (0, 20)], but I can't really figure it out. Or maybe this could be done with the RichTextLabel's custom fonts' property "extra_spacing_char"?
Any help is mich appreciated!

(Weirdly enough, setting the shake rate to 0 and the level to e. g. 80 clearly changes the position of the digit (without shaking around, obviously). But there must be a proper way to do this...)

Like this:

[offset x=0 y=20]  

Code would be something like this

extends RichTextEffect
class_name RichTextOffset

var bbcode = "offset"

func _process_custom_fx(char_fx):

    var x = char_fx.env.get("x", 0)
    var y = char_fx.env.get("y", 0)

    char_fx.offset = Vector2(x,y)

    return true

The according video:

Thanks to art_critique on reddit!

Godot version 3.2.3
in Engine by (525 points)
edited by

1 Answer

0 votes
Best answer

For the mutiple effects example above, your color and shake tags are nested incorrectly. This should work show both effects at the same time.

[right][color=blue][shake rate=15 level=20]1[/shake][/color]23456[/right]

For the vertical position, I'd guess you could do that via a custom effect, and the position property. See near the bottom of this page:

by (22,704 points)
selected by

Errr... Wait. Either I didn't read your question closely enough or it's been updated since. Either way, the code you posted does indeed work as you want. With that code, and the setup indicated in the video you linked, this BBCODE text works as intended:

[offset x=0 y=-5]1[/offset]2345

That offsets the 1 digit up by 5 pixels...

The order of opening and closing tags is indeed the point. And the offset position tag is exactly what I was looking for.

Thanks for your help!
(Yes, I added those edits in the meantime. Sometimes things go quickly! : )

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.