Icons / Sprites in BBText Object

Like the title says, if at all possible, could some sort of “Icon” code be implemented into BBText Objects to give full control over text?

The more im thinking about tooltips and RPG elements the more id really like this feature, and according to a google search, so would a lot of people using GDevelop.

The BBCode can already reference a font file and change it mid text, so could this be applied to a image file too?

For example, to make everything simple we could only use sprites that have already been imported into the project, and prompt it by its name.

The sprite would be created from its origin point to give control over alignment.

Then we could do something like this for example:

“You just got [sprite]Alpple_Icon[/sprite] x”+ToString(AppleCounter)+“!! [color=orange]Awesome![/color]”

Translating to…

“You just got :apple: x3 !! Awesome!”

…imagine “Awesome” is orange in color :stuck_out_tongue:

This would be so helpful in so many ways and its something a lot of people seem to want.

We can do something like this right now using multiple objects, but thats only really useful for single lines and a nightmare for texts with line breaks or “long tooltips”.

We can also use bitmap text for something like this, but that would involve a lot more custom work…

If adding some sort of extra BB Code to reference project sprites would be at all possible… it would be so awesome to have!

3 Likes

I would be super cool if they update it, I’ve opened a topic about it yesterday (What is the best way to "Replace some texts with icons"? - #4 by Keith_1357).

I think it is a must have feature, I hope they update it soon.

1 Like

Just to set expectations, both normal text and bbtext involve a base PixiJS object which doesn’t support injecting other objects into it.

It also uses the browser’s text rendering to render the fonts, spacing, and appearance, so I’m not sure the GDevelop devs could modify that behavior even if they took on this feature request.

While it was briefly touched on above, if you’re looking to do this today you will have to do some footwork and make your own bitmap font that includes the sprite images you want, then use those in your Bitmap font objects.

e.g. instead of having an option for ¬ (alt+0172) in your bitmap font, you replace it with your Apple Icon sprite in the font atlas image. Then when you write up your text string you’d just do alt+0172 for where you want the apple to appear.

This will get you going today, even if this feature isn’t possible/never gets added.

1 Like

I just woke up and this is off the top of my head… so the idead needs a lot of work but…

How about baking a hybrid system into BBText? Something that does all the calculations and heavy lifting for you… kinda like…

“I just got an :apple: ! awesome,
right? but it was :green_apple: , and
i dont like those.”

…so to make this happen right now using BBText, we would need a total of 7 objects, or if we use events to change the texts, we would need 1 text and 2 sprites.

How about if we could do an expression like…

“I just got an” [sprite]Red_Apple[/sprite] “! awesome,”
"right? but it was [sprite]Green_Apple[/sprite] “, and”
“i dont like those.”

By doing this, GDevelop would use the same texts object for each text segment but change their content, kinda how we can do with events, but it would also calculate where each of them should go.

So the first one would be the “Origin” and where all other text and object segments would base their position on.

Then, following the example above, :apple: would be placed at “Text segment_1.X() and Y() + Text_segment_1.Width()”,

The next one, “Text Segment 2”, would be at “Sprite1.X() and Y() + Sprite1.Width()”

…and so on…

The line breaks, would be the same but changing “Width” for “Height”.

If it was possible to make some sort of automated system to make this, that would make creating custom text with sprites super easy!

What do you think of this? @Silver-Streak

1 Like