T2dTextObject
by Very Interactive Person · in Torque Game Builder · 02/17/2007 (11:17 am) · 14 replies
Anyone knows where i can find some good documentation on how to use the t2dTextObject in TGB 1.3?
It isn't in the official docs. When I do a forum search I only find the old textobject... but it looks like things are a bit different now.
I want to create a new textobject dynamically in script. Looks like the setText() method no longer exists, and becuase I can't seem to find any information on this new object, I don't know how to use it. Can someone give me an example on how to do this?
It isn't in the official docs. When I do a forum search I only find the old textobject... but it looks like things are a bit different now.
I want to create a new textobject dynamically in script. Looks like the setText() method no longer exists, and becuase I can't seem to find any information on this new object, I don't know how to use it. Can someone give me an example on how to do this?
#2
02/17/2007 (4:14 pm)
Yea, text still ends up looking funny for me, but I haven't taken the time to seriously look at it. Ah wells :P
#3
If the text itselfs looks broken your system perhaps is below min requirements (Intel Onboard older than Intel Extreme 2 or some SiS / S3)
02/18/2007 (2:14 am)
What do you mean by "looking funny"If the text itselfs looks broken your system perhaps is below min requirements (Intel Onboard older than Intel Extreme 2 or some SiS / S3)
#4
02/18/2007 (2:06 pm)
@Marc - Look on the thread that Tom linked to. It's not a big deal. It's def not my system specs - although who knows, maybe it's a vid card driver issue or something. Anyways, it looks good enough to at least beta test the game. Maybe it'll get fixed in a point release (if it is TGB and not me screwing up). Otherwise I'll bother with it again at the polishing stage. *shrugs*
#5
But I haven't check that yet.
02/18/2007 (2:51 pm)
Ah the font pixalation issue. The only idea I came up with so far is that mipmapping is causing this issue when the choosen font size is not a power of 2 ie the font or its mipmap gets stretched and thus filtered. (thats an issue I know of an engine I worked with before I switched to TGB).But I haven't check that yet.
#6
For me this is a bit of a problem.
What's the correct way to set the font size? LineHeight? And keep aspect ratio set to 1?
02/19/2007 (1:14 am)
Texts look very pixelated indeed. Can't seem to get them sharp. That was my main problem, thought I was doing something wrong in the scripts, and that's why I asked here. For me this is a bit of a problem.
What's the correct way to set the font size? LineHeight? And keep aspect ratio set to 1?
#7
02/19/2007 (5:13 am)
Did you look at the code in the thread I linked to above? That's what I've used in the past and it works for me in most cases (but not for Drew ;)
#8
It says "Loading platform font failed, trying font fallbacks" in the log.
02/19/2007 (7:05 am)
Hmmz... that code crashes my game.It says "Loading platform font failed, trying font fallbacks" in the log.
#9
02/19/2007 (8:27 am)
Can you post a simple snippet where you used it? If you get one value wrong, then you can end up with no proper fontsizes and everything breaks :)
#10
02/19/2007 (9:03 pm)
Quote:Texts look very pixelated indeed. Can't seem to get them sharp.Same problem here, I also tried Tom's fix, but it's still very pixelated.
#11
Can someone just explain the meaning, and the relation between the following parameters:
lineHeight = "64";
aspectRatio = "1";
fontSizes = "24";
What's the difference between the fontSizes and the lineHeight? These values give me a more or less acceptable result, but its still not looking good. How do you guys get it to look right? Becuase right now, to me, it looks like t2dTextObject is just broken and useless. Please help.
03/08/2007 (2:39 am)
Didn't work on this project for a while, but now i'm cleaing it up... and I'm running into that font problem again.Can someone just explain the meaning, and the relation between the following parameters:
lineHeight = "64";
aspectRatio = "1";
fontSizes = "24";
What's the difference between the fontSizes and the lineHeight? These values give me a more or less acceptable result, but its still not looking good. How do you guys get it to look right? Becuase right now, to me, it looks like t2dTextObject is just broken and useless. Please help.
#12
03/09/2007 (12:26 am)
Anyone?
#13
Only using 'fontSizes = "24";' means all text objects regardless of textobject scaling will render as if you drew a 24-point font in Photoshop, saved it to a bitmap image and used that as a sprite imagemap (e.g. pixellated at anything substantially above the original 24 point size).
If you do something like fontSizes = "24 48 64 128" and scale a textobject it'll select the closest font size to the pixel height of the scaled text.
03/09/2007 (2:16 am)
LineHeight refers to how closely adjacent lines of text are rendered (it's the space between the horizontal center-lines of each line of text). fontSizes is a space-delimited list of sizes that the bitmap font cache files (.uft's) will be created in. Torque internally only uses these bitmap versions for text.Only using 'fontSizes = "24";' means all text objects regardless of textobject scaling will render as if you drew a 24-point font in Photoshop, saved it to a bitmap image and used that as a sprite imagemap (e.g. pixellated at anything substantially above the original 24 point size).
If you do something like fontSizes = "24 48 64 128" and scale a textobject it'll select the closest font size to the pixel height of the scaled text.
Associate Tom Eastman (Eastbeast314)
Here's one:
new t2dTextObject() { scenegraph = SceneWindow2D.getSceneGraph(); position = "-10.000 -10.000"; size = "48.025 11.000"; text = "Text!"; font = "Arial Black"; wordWrap = "0"; hideOverflow = "1"; textAlign = "Center"; lineHeight = "11"; aspectRatio = "1"; lineSpacing = "0"; characterSpacing = "0"; autoSize = "1"; fontSizes = "80"; textColor = "0 0.0313726 1 1"; hideOverlap = "0"; };That will load a text object all nice, but getting to behave the way you want can require some tweaking. You don't really need all of those fields, but there they are anyway. The important ones (like size, wordwraphideOverflow, lineHeight, fontsizes, and hideOverlap) are what will need to be tweaked to get it looking how you want. Fiddling will probably be required.
The fontsizes stuff is really annoying. Basically, the levelEditor will do it for you if you create the object in the editor, but otherwise you have to initialize it yourself. Check out this thread for some code to get it working right (or not in Drew's case).
And, finally, in the TGB reference doc, when I added the text object stuff, there's not really a spot to discuss how the fields work, so it has the functions and the fields. All the fields there can be directly changed, like this:
Hope that made sense!