Hi there,
I'm a super newbie and this question might sound silly but I can't find how to set the colour of a Text object. I mean, by default, if you draw a Text object, it displays white text, and I didn't find what property I should change to display black text, by exemple.
Sorry if this is obvious, and thank you for your help !
Setting the colour of a Text object
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Setting the colour of a Text object
Hi and welcome to the forums.
First question, do you really want to use a Text object? Or would you be fine with just printing stuff to the window?
First question, do you really want to use a Text object? Or would you be fine with just printing stuff to the window?
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Setting the colour of a Text object
Either way, you can set the color of the entire text with [wiki]love.graphics.setColor[/wiki] before you draw it. Alternatively, love.graphics.print/printf and Text:set/add/etc. all optionally accept a table in the form of {{r, g, b}, "text", {r, g, b}, "more text", ...} which allows different parts of the same text to have different colors.
Re: Setting the colour of a Text object
Thanks for both answers.
@zorg : I use a Text object because I also use the Text:getWidth method.
@slime : I've tried your solution and it worked perfectly. Thanks a lot.
@zorg : I use a Text object because I also use the Text:getWidth method.
@slime : I've tried your solution and it worked perfectly. Thanks a lot.
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Setting the colour of a Text object
You can also do [wiki]Font:getWidth[/wiki](str) on a Font object though.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Who is online
Users browsing this forum: No registered users and 2 guests