Fading text (GuiTextCtrl)?
by Rubes · in Torque Game Engine · 09/07/2007 (6:59 pm) · 7 replies
Hey folks, just a (hopefully) quick question:
Is there an easy way to have text (like, say, in a GuiTextCtrl) fade in and out? The only way I could figure out to do this is to access the GuiTextCtrl's profile, and alter the profile's fontColor alpha value.
This is probably a no-no to do this, but it works, and I can't figure out any other way. Problem is, a nice smooth fade can only be done by repeatedly calling a function to decrement/increment the alpha value by a small amount, which tends to slow everything down far too much.
I suspect there will probably have to be a C++ solution to this, but just wondering if anyone knows of an existing solution that I've missed.
Thanks...
Is there an easy way to have text (like, say, in a GuiTextCtrl) fade in and out? The only way I could figure out to do this is to access the GuiTextCtrl's profile, and alter the profile's fontColor alpha value.
This is probably a no-no to do this, but it works, and I can't figure out any other way. Problem is, a nice smooth fade can only be done by repeatedly calling a function to decrement/increment the alpha value by a small amount, which tends to slow everything down far too much.
I suspect there will probably have to be a C++ solution to this, but just wondering if anyone knows of an existing solution that I've missed.
Thanks...
#2
09/07/2007 (9:31 pm)
Not necessarily scrolling up, just fading in and out. Thanks, I'll start checking it out.
#3
profiles seem similar to datablocks, which it would be a no-no to modify, but they're not really because they're not transmitted over the wire. Of course, all GuiTextCtrls using that profile will all fade simultaneously, which may not be what you want. Another option would be to use a GuiMLTextCtrl with some tags, a rewrite the contents of the ctrl every however often with different tags.
.. actually i'm not sure the color tags support alpha, so maybe not.
09/07/2007 (10:04 pm)
Rubes, changing the value of a field in a Gui profile seems totally legit to me.profiles seem similar to datablocks, which it would be a no-no to modify, but they're not really because they're not transmitted over the wire. Of course, all GuiTextCtrls using that profile will all fade simultaneously, which may not be what you want. Another option would be to use a GuiMLTextCtrl with some
.. actually i'm not sure the color tags support alpha, so maybe not.
#4
Frank's right, it should be done in the engine. Fortunately, somebody already did something just like this for a fading transparent bitmap control (which I'm already using), and amazingly the code can be transferred over to GuiTextCtrl almost verbatim.
I'm compiling it now, and if it works I'll submit it as a resource.
09/07/2007 (10:32 pm)
Thanks, Orion. I actually set up separate profiles for the individual GuiTextCtrls, so modifying the profiles is not that big of a problem for other controls. The real problem is that by implementing the fade step-by-step in script, it's just so dang slow it causes the whole app to grind noticeably.Frank's right, it should be done in the engine. Fortunately, somebody already did something just like this for a fading transparent bitmap control (which I'm already using), and amazingly the code can be transferred over to GuiTextCtrl almost verbatim.
I'm compiling it now, and if it works I'll submit it as a resource.
#5
09/07/2007 (10:52 pm)
Wow, worked perfectly. I'll try to get this up as a resource tomorrow.
#6
09/08/2007 (10:09 am)
I love how there is so much code out there that sometimes it is just "plug and play". Good going on getting it to work.
#7
09/08/2007 (12:29 pm)
Thanks! Here's the resource if you want to check it out before it's approved...
Torque Owner Frank Carney
DemolishunConsulting Rocks!