Setting color on t2dTextObject
by Steven S · in Torque Game Builder · 11/02/2007 (12:47 am) · 5 replies
I have a GuiTextCtrl working from within the GUI Editor, but I would like to move it directly as a t2dTextObject within the Level. I am wondering how to set the color on the t2dTextObject.
The Wiki page is empty. And I did a search for "t2dTextObject" and was returned 18 items. None of which appeared to have the answer.
I noticed a reference to the t2dTextObject in my t2d layer file. There is a textColor item. I edited this and it still did not work. I set textColor on my object from within script and received an error.
The text is always appearing as white.
Thanks for any information on how to change the color.
The Wiki page is empty. And I did a search for "t2dTextObject" and was returned 18 items. None of which appeared to have the answer.
I noticed a reference to the t2dTextObject in my t2d layer file. There is a textColor item. I edited this and it still did not work. I set textColor on my object from within script and received an error.
The text is always appearing as white.
Thanks for any information on how to change the color.
#2
I'm not even quite sure if a t2dTextObject is the right way to go. I am trying to come up with a name entry screen. The screen below is from a game I am converting from SDL.NET, but is an example of what I want to do. It was a speedgame contest, so I hope to get a better looking interface this 2nd time through.

I want the entered name (Steve) to be a t2dTextObject so when you mouse over, I can cause the text to grow in size. I have the alpha characters currently in place but I actually have this all set up as a Level and NOT a GUI. I needed a level so I can create collision marks for each t2dStaticSprite letter, signifying the allowable mouse click area.
11/02/2007 (9:39 am)
Thanks. I was thinking of playing around with the Blending options in the Level Editor, but wasn't sure if that would help. I'll give this a second look.I'm not even quite sure if a t2dTextObject is the right way to go. I am trying to come up with a name entry screen. The screen below is from a game I am converting from SDL.NET, but is an example of what I want to do. It was a speedgame contest, so I hope to get a better looking interface this 2nd time through.

I want the entered name (Steve) to be a t2dTextObject so when you mouse over, I can cause the text to grow in size. I have the alpha characters currently in place but I actually have this all set up as a Level and NOT a GUI. I needed a level so I can create collision marks for each t2dStaticSprite letter, signifying the allowable mouse click area.
#3
Within your common/gui directory in your game folder, there should be a file called profiles.cs. In this file are the profiles that you use to apply to objects in your GUI, below is a snippet from the cs file:
So, what you can do is create your own GUI profile and modify the font color, size, orientation etc so that you can use them in your game. Then, when you mouseover it, you should be able to just change the profile of the object to the one you made!
I hope that helped out a little bit.
11/02/2007 (2:56 pm)
Ahhhh, what you may want to do is create your own GUI profile. What this will do is allow you to select the custom profile from the drop down menu for your GUI object, or, you can set it via script.Within your common/gui directory in your game folder, there should be a file called profiles.cs. In this file are the profiles that you use to apply to objects in your GUI, below is a snippet from the cs file:
if(!isObject(GuiTextProfile)) new GuiControlProfile (GuiTextProfile)
{
fontColor = "0 0 0";
};
if(!isObject(GuiMediumTextProfile)) new GuiControlProfile (GuiMediumTextProfile : GuiTextProfile)
{
fontSize = 24;
};
if(!isObject(GuiBigTextProfile)) new GuiControlProfile (GuiBigTextProfile : GuiTextProfile)
{
fontSize = 36;
};So, what you can do is create your own GUI profile and modify the font color, size, orientation etc so that you can use them in your game. Then, when you mouseover it, you should be able to just change the profile of the object to the one you made!
I hope that helped out a little bit.
#4
Originally, I did use a GUI and set up a profile, but I am trying to get away from the GUI for this particular screen and control. After reading your post I tried some more ideas. I gave the GUITextCtrl a class of NameTextClass and did something like this:
function NameTextClass::onLevelLoaded(%this, %scenegraph)
But it never got called. So I must not have been doing something right. Any help there will be nice, but I'm sure I'll figure it out later. It's not a priority to figure it out at this time.
In any case, I looked up t2dTextObject in the TGB on-line Documentation and found the description for textColor. It uses values between 0 and 1. I did an echo for textColor and saw it was "1 1 1 1" so I knew it needed RGBA.
I ended up creating an onLevelLoaded and set %this.textColor = "0.0 0.5 1.0 1.0"; and saw the text as a bluish color. I tried various other settings and saw the colors change.
In any case, the blending option is a much better option for me.
11/03/2007 (4:52 pm)
Thanks Phillip! Using blending from within the editor worked GREAT! That was it.Originally, I did use a GUI and set up a profile, but I am trying to get away from the GUI for this particular screen and control. After reading your post I tried some more ideas. I gave the GUITextCtrl a class of NameTextClass and did something like this:
function NameTextClass::onLevelLoaded(%this, %scenegraph)
But it never got called. So I must not have been doing something right. Any help there will be nice, but I'm sure I'll figure it out later. It's not a priority to figure it out at this time.
In any case, I looked up t2dTextObject in the TGB on-line Documentation and found the description for textColor. It uses values between 0 and 1. I did an echo for textColor and saw it was "1 1 1 1" so I knew it needed RGBA.
I ended up creating an onLevelLoaded and set %this.textColor = "0.0 0.5 1.0 1.0"; and saw the text as a bluish color. I tried various other settings and saw the colors change.
In any case, the blending option is a much better option for me.
#5
One Idea may you can try also. Instead of giving its classname and calling onLevelLoaded for its class, just give a name to this object during declaration and then call onLevelLoaded function for it
like.....
function myTxtObj::onLevelLoaded(%this)
{
//place your color changing code
}
it might work.
cheers !
11/07/2007 (12:14 am)
Hi Steven,One Idea may you can try also. Instead of giving its classname and calling onLevelLoaded for its class, just give a name to this object during declaration and then call onLevelLoaded function for it
like.....
function myTxtObj::onLevelLoaded(%this)
{
//place your color changing code
}
it might work.
cheers !
Associate Phillip O'Shea
Violent Tulip
I do not know the blending codes off my head, just check em out in the docs.