What is the best way to "Replace some texts with icons"?

From these screenshots
image

image

How to have icons in a textbox without having to manually place the icons

Can we replace string with an icon??

Like this Gives [Gold] 1,
Gives [Gold] 9 for each [Milk]

I couldn’t find any understandable solutions.
In the event sheet what should I do?

I’m not sure there’s an easy way without multiple objects.

You could use emoticons but they’re device dependent. So, they would look different on different OSs.

Maybe, you could use a bitmap font where certain characters are icons or emoticons. That would make it consistent. I haven’t messed with that. You can make your own or maybe find something already made.

https://wiki.gdevelop.io/gdevelop5/objects/bitmap_text/

Using a separate text and sprite would be the best way but it would be tricky to make it dynamic. You would need to add a text object, add a sprite beside it, add another text object and so on. Not impossible but not easy for anything too complex. I can’t even imagine line breaks.

You can type the emoticon or character or use the Regular expression’s replace action to replace something like [cat] with the character or use it with some other command. Regular expression has a lot of functions.

The easiest method is structured. A line of text and a sprite or a sprite and a line of text.

1 Like

Hmm this looks more difficult than what I thought, I will try.

1 Like

It just depends on what you’re doing. Fixed is easy. Dynamic more difficult. Emoticons or a bitmap font seems the easiest. It would handle the positioning.