"Highlighting" Text in a menu?
Moderator: Coders of Rage
"Highlighting" Text in a menu?
Well let's say I had a menu and when the mouse hovered over it, the text was to change to a different color.
How would I go about doing that? I was thinking I'd create two colors, and then have it check each option to see if the mouse is hovering over it... But something tells me there's a better way to do it, so is there a better way to do it than individually checking each option, and then setting its color?
How would I go about doing that? I was thinking I'd create two colors, and then have it check each option to see if the mouse is hovering over it... But something tells me there's a better way to do it, so is there a better way to do it than individually checking each option, and then setting its color?
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: "Highlighting" Text in a menu?
Just treat it like collision detection, but with mouse coordinates. So I guess that while there is a more efficient implementation, that one should do fine.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Re: "Highlighting" Text in a menu?
One of these days... I'll find something better.... >.>MarauderIIC wrote:Just treat it like collision detection, but with mouse coordinates. So I guess that while there is a more efficient implementation, that one should do fine.
Re: "Highlighting" Text in a menu?
Wait... Now that I think about it, I'd have to re-render the text every frame... And that means I'd have to keep deleting the text I rendered... There's no function... or maybe a different text library, where I can do something like "set_color()" ?
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: "Highlighting" Text in a menu?
Well, no, not really. Just re-render when mouse is over it but it wasn't last frame, and re-render when mouse isn't over it but it was last frame.XianForce wrote:Wait... Now that I think about it, I'd have to re-render the text every frame...
And you can always draw on top of it without erasing it.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Re: "Highlighting" Text in a menu?
oh yeah... cause creating the SDL_Surface* allocates the memory, not the text rendering...MarauderIIC wrote:Well, no, not really. Just re-render when mouse is over it but it wasn't last frame, and re-render when mouse isn't over it but it was last frame.XianForce wrote:Wait... Now that I think about it, I'd have to re-render the text every frame...
And you can always draw on top of it without erasing it.
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: "Highlighting" Text in a menu?
I'm not sure if you're being sarcastic (in which case we're misunderstanding each other's problem/solution) or not :)XianForce wrote:oh yeah... cause creating the SDL_Surface* allocates the memory, not the text rendering...
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: "Highlighting" Text in a menu?
I'm pretty sure he was just agreeing with your solution. Didn't seem very sarcastic to me.MarauderIIC wrote:I'm not sure if you're being sarcastic (in which case we're misunderstanding each other's problem/solution) or notXianForce wrote:oh yeah... cause creating the SDL_Surface* allocates the memory, not the text rendering...

Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
Re: "Highlighting" Text in a menu?
nope, I'm not being sarcastic (I've learned computers suck at sarcasm... so I try not to use it xD)MarauderIIC wrote:I'm not sure if you're being sarcastic (in which case we're misunderstanding each other's problem/solution) or notXianForce wrote:oh yeah... cause creating the SDL_Surface* allocates the memory, not the text rendering...
Re: "Highlighting" Text in a menu?
If it's sarcasm you should put one of these
at the end... Example:
"Yeah, everybody loves Raymond is the best comedy on tv
"

"Yeah, everybody loves Raymond is the best comedy on tv

