A Note on the t2dTextObject Class
by Eric Robinson · in Torque Game Builder · 02/20/2007 (10:47 pm) · 3 replies
This post exists for anyone wondering how to actually change text on official t2dTextObject objects.
SetText
As it turns out, most of the t2dTextObject's data is directly accessible in this way from script. From the TGB Reference file.
I was confused about how to use this stuff and figured that perhaps other people may be confused as well. Hope this helps someone.
SetText
// %object is a t2dTextObject. %object.text = %someStringToShow;GetText
// %object is a t2dTextObject. %textString = %object.text;
As it turns out, most of the t2dTextObject's data is directly accessible in this way from script. From the TGB Reference file.
text //The text that is displayed by the object. font //The name of the font to render the text with. wordWrap //Whether or not text should automatically wrap to the next line. hideOverflow //Whether or not text outside the object bounds should be hidden. textAlign //The alignment of the text within the object bounds. lineHeight //The height, in world units, of each line. aspectRatio //The ratio of a characters width to its height. lineSpacing //The amount of extra space to include between each line. characterSpacing //The amount of extra space to include between each character. autoSize //Whether or not the object should be scaled when the text is changed. fontSizes //Space separated list of font sizes the text object should use.
I was confused about how to use this stuff and figured that perhaps other people may be confused as well. Hope this helps someone.
Torque 3D Owner Stephen Zepp
C# has the concept of "implicit accessor methods" that are called whenever you appear to be directly accessing a variable or field, and we've found it quite useful as well as much cleaner in use, so it's becoming a future standard for Torque objects.