+1 vote

Hi everyone,

I wonder how I could have a single character in a text within a label to be animated under one certain circumstance.

I have a RichTextLabel connected to some number- and a comma-button. Only one comma is possible, so entering one makes the comma-button "inactive"... it still registers tapping though, so in my func _on_Button_button_comma_pressed_while_disabled(): I can apply all kinds of "there's-already-a-comma-written!"-reactions (like e. g. a rapidly blinking cursor).

Now I'd like the comma itself in the text to blink a couple of times when that function is triggered. Could I somehow find(',') or get(",") and then maybe apply some Tween-animation or even bbcode? Or is there an easier way I just can't think of?

Godot version 3.2.3
in Engine by (365 points)

3 Answers

0 votes

i dont think there is any built in function to do it, but you can create your own system using replace(text, ",", " ") to create the blink effect (replace , with an empty space), linked to a timer that will repeat this action a couple of time

by (1,436 points)
0 votes

Hey there, yes you could! let me elaborate!

lets assume you have some code like:

onready var my_rich_text_label = $Rich_Text_Label

then in your function you could have

_on_Button_button_comma_pressed_while_disabled():
        text = my_rich_text_label.bbcode_text
        text.replace(",","[custom_bbcode_tag],[/custom_bbcode_tag]")
        #maybe then wait a little bit and replace back the comma so the animation stops

you'll have to implement your custom bbcode tag, i suggest reading the documentation on that subject

by (16 points)
0 votes

Hi Andrea and astrale,

thanks for your suggestions, I'm sure this is exactly what I'm looking for. The visible mentioned in the docs will be what I'm aiming at.

I already have several bbcode working in my RichTextLabel, including var templateAlwaysAllRight = "[right][color=blue]{alwaysAllRight}[/color][/right]" for some alignment. Now, when I'm adding e. g. text.replace(",","[color=green],[/color]"), entering 1,2 and then tapping the disabled , again, it leads to [right][color=blue]1,2[/color][/right] being displayd as text in my RichTextLabel...

This is about as far as my beginner-understanding goes at this point, so I wonder (and guess): two "separate" bbcodes can't apply to the same object? So would I need to have them both combined in one? Or am I missing something else?

EDIT:
The docs describe in Custom BBCode tags (e. g.)

var bbcode = "ghost"

func _process_custom_fx(char_fx):
...

that can then be used as [ghost] ... [/ghost], but I don't see how ghost is connected to the function (so how ghost would "know" its own variables). So I wonder how I can make [ghost],[/ghost] work (as [custom_bbcode_tag] in your example)?

by (365 points)
edited by
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 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 webmaster@godotengine.org with your username.