I would use a vector shape icon representation version of the resource sprite for now if you could… when we can dynamically change the color of text within a body of text it would be more ideal. Main issue is you would want the placement dynamic to better support localization, but I don’t think you can get the information you would need to do that right with current features. One work around would be to use two text nodes and then build the phrase string + icon + string. Get the width from the table gui.get_node provides from a text node. Only do with single line text.
It’s not supported and I have seen no one trying to build it themselves. There was a similar request a while back from a team that wanted emoticons in chat messages. Contact me on HipChat @GregorGullwi.
It’s probably much easier to do it all in GUI. Here’s an example with two text nodes around a texture. I set the pivot point to east and west to make the text stick to the edge of the texture (no width lookup needed):
Thanks @sicher! I’m not sure it will work well with anchoring of the text though. If the text is localized, the left most text size is unknown and it will look unaligned I think?
It would since its pivot point is to the right. Expand the text and the node grows to the left.
Maybe it’s possible for you Defold guys to allow us to use our own bitmap-fonts instead of generating one from a TrueType / OpenType font file? Or let us access and modify the bitmap-font generated by the editor.
This way we could not only use multicolored characters (e.g. for retro games), but also add any icons we need to the font by ourselves as special characters.
That would be a cool idea… have a list of extension glyphs and their associated textures + character codes to use.
Nice!
I guess the manual could need an update then…
Things that I would want from text engine:
- Changing text style (font, color, maybe underscore etc) of parts of text
- Inline sprites
- Links (throwing event when clicking (EDIT: or hovering) on the part of the text)
- Tables with colspan and rowspan
- EDIT: scrollbar
Yes, it’s a lot, but I think not a lot a lot.
What is your use case? We do have webview support that might work for you.
Maybe, if there were any guide of what it is and how to work with it. Is it gui element? Is it GameObject property?
You can use it to open web browser overlays with HTML content in your iOS/Android app. If you need to display large amounts of text with elements it can be a good option. Press button, html file in your project is opened, can press a button on the html page to then close the overlay and return to game view. Style with CSS etc. to make it look like it is native to your game. You could make entire menus with this, but big problem is it only works with iOS/Android builds as it uses their native webview functionality. Webview could be added to desktop targets with http://www.awesomium.com/ and HTML5 could be supported too in various possible ways…
OK, use cases… Anything with more than trivial texts. NPC interactions, in-game reference, logs etc.
For example, if you want to have NPC selling things, having a table with price column, how they look column and stats column, and scrollable if too long would be very handy. In Visual Novels you will need a long scrollable talk log. Many concepts are better expressed with icons, instead of texts. such as “I’ll give you [carrot.jpg]x3 for [gold.jpg]x10”. Or “This gun is best against [zombiehead.jpg]”. Links will allow making cross-references and tooltips. For example, “Kill [meanine.jpg|ref = meanie43] near [planet.jpg|ref = planet128]”, with tooltip showing mini-map where this planet is, and click on planet link sets your autopilot there.
All of these are perfectly possible to build with GUI elements. And I would argue that it would probably be more flexible since you can manipulate all elements individually. Scroll them in a view, drag-drop etc. Defold users would benefit from a GUI library that helps implementing some of that functionality though.
Possible - yes, easy - no. On the other hand, if you consider long complex texts in games a bad practice, then Defold is doing great job discouraging them
baturinsky:
The way Defold is built and the way it try to solve things is to only provide small building blocks so everyone can build up their own libraries. this is really intentional and in my opinion the only way to go. Being experienced in quite a few engines I know for a fact that it doesn’t really matter how many tools and solutions you put in there, there will always be something missing or something not really behaving the way you want it to behave.
Even if you would get eg. a button feature, a user would like the button to animate when clicked instead of changing image. Or both. And have sound. And have a function connected to it. Or not. It would be autoremoved when clicked. And state saved. Or not. It would actually have two functions tied to it being toggled.
Etc…
Instead of supporting all cases is better to give tools so the developer can create it him/herself. That’s where an engine could shine (or not).
Having features like a gui table would raise multiple time more usercases and questions than the button one and every user would like to have it behave in different ways when scaling, adding sprites in the table, visible 99-sliced borders etc etc.
I’m just trying to explain that it is sometimes not a good thing to make an engine bulky with millions of features that still maybe don’t even fit your purposes and you end up writing your own in the end. I say, focus on good small building blocks and develop whatever tools you need for your game. That is the design of Defold.
But as Sicher says. If Defold focus on giving us a lot of good basic tools there is a good chance that the community builds great gui libraries that solves some basic things like a buttons, scrollbars or even images within text.
I agree that the basic building block should be in place rather than monolithic solutions, but I also would love to see a slightly more higher level “official” parts, you know for the users that are happy with it