SFML community forums
Help => Graphics => Topic started by: supdawg on December 08, 2012, 01:34:43 am
-
the subject says the question. like for example, can i have the words "New Game" but New is red and Game is blue? or do i need to make two different sf::Texts?
-
It should be easy to do if you copy the code of sf::Text and change some things(just add a method that takes index and color and colors the vertices of the quad at that index, but keep in mind underline is a quad too and it'd not last untill next time quads are recreated so you'd have to do it last:. set font, size, style, text and then set colors), but not with sf::Text , I don't think. And well, the simplest approach is few instances of sf::Text but if you wanted something like 20 letters, that do not change, each in different color, then you should really roll own class up.
-
oh i see. so wrapping sf::Text is the best option. well i guess itll be a bit of work but i only have a few words that have different colors so far so ill just create multiple sf::Texts each with a different color.
-
what I do is having a wrapper class which accepts format codes (\n, \c[1] for color, \u for underline, etc.) and draws the text into a RenderTarget when update.
Then you only have to draw this RenderTarget into screen ;)
-
i see. thats an interesting way of doing things. thanks for all the help