Text object
by PeterB · in Torque Game Builder · 11/07/2007 (5:20 pm) · 17 replies
I'm trying out the text objects (the sprites you can make in the level editor) for the first time in 1.5.
They look rather jagged. No matter what size or font I choose, they just don't look smooth. Am I missing something?
They look rather jagged. No matter what size or font I choose, they just don't look smooth. Am I missing something?
About the author
#2
Phillip, please correct me if I'm wrong.
11/07/2007 (10:21 pm)
Quote:I suppose this scale is correct for a default camera size only (100x75 units) and default screen resolution (800x600). For other cameras and screens it may be calculated as screen_height / camera_height.
Just remember 1 unit = 8px and resize your text object to fit the font size you set and everything will be nice ;)
Phillip, please correct me if I'm wrong.
#3
11/08/2007 (12:16 am)
I'm pretty sure that the 8px = 1unit thing is standard regardless of the camera size.
#4
Small example.
1. Set the camera size different than its default resolution (eg 200x150).
2. Create the imageMap from some 800x600 image.
3. Drop the imageMap to the scene.
4. Set an image size to 200x150 and an image position to 0, 0.
5. Run the level.
What we can see? Screen area has been occuped by the image we placed to the level!
Hmmm. Image width is 800, camera width is 200.
1unit = 4 pixels!
What's wrong?
11/08/2007 (1:46 am)
I'm sorry. Something is wrong here.Small example.
1. Set the camera size different than its default resolution (eg 200x150).
2. Create the imageMap from some 800x600 image.
3. Drop the imageMap to the scene.
4. Set an image size to 200x150 and an image position to 0, 0.
5. Run the level.
What we can see? Screen area has been occuped by the image we placed to the level!
Hmmm. Image width is 800, camera width is 200.
1unit = 4 pixels!
What's wrong?
#5
Say for instance you change your camera to 200x150, you need to change the resolution of the game to 1600x1200 in order for the ratio to be the same.
11/08/2007 (2:27 am)
If you change the camera size, you need to change the display resolution in the same ratio. This is why your objects appear to be a bit crazy size wise.Say for instance you change your camera to 200x150, you need to change the resolution of the game to 1600x1200 in order for the ratio to be the same.
#6
11/08/2007 (3:15 am)
Quote:Is it mean if I would like to change the display resolution than I must change the camera size as well? But it is mean that I must change a size of all sprites I use to keep the scale of a game world! Moreover, I will need to change collision bounds, a speed of objects, interaction algorithms, etc. It is strangely for the good game engine.
If you change the camera size, you need to change the display resolution in the same ratio.
#7
11/08/2007 (3:32 am)
If you change the size of the camera, you should keep the ratio of the display resolution in the same proportion. You do not have to change the size, speed, collision bounds or anything else for each object.
#8
I would like to change the display resolution 800x600 -> 1600x1200. What the camera size I should set (the current camera size is 100x75)?
11/08/2007 (3:46 am)
OK.I would like to change the display resolution 800x600 -> 1600x1200. What the camera size I should set (the current camera size is 100x75)?
#10
Phillip, excuse me please for my obstinacy, but it is very important for me to explain this theme because it is a backgound for succsessful games. Thank you.
EDIT: Excuse me for my english.
11/08/2007 (9:51 pm)
Now, I have an image which occuped a whole screen (100x75, eg a level background) and I would like to keep its appearance. Do I need to change a size of this image?Phillip, excuse me please for my obstinacy, but it is very important for me to explain this theme because it is a backgound for succsessful games. Thank you.
EDIT: Excuse me for my english.
#11
11/09/2007 (8:08 am)
Thanks Phillip for explaining this. It really helps in understanding text objects. It has also helped me understand what the x and y tile size values actually mean for tile layers. That explains why a 1 value is NOT a pixel. Everything is sort of coming together now. I had been somewhat confused on the whole camera and design resolution relationship.
#12
This code let me to get fine text objects for all screen resolutions. Is there different approach to show fonts correctly?
11/12/2007 (1:46 am)
In my game I use the custom functions to adjust font size.// tText is a class for all text objects
function tText::adjustSize(%this)
{
// Scale between window height and camera height
%scale = getWord(sceneWindow2D.getWindowExtents(), 3) / (getWord(sceneWindow2D.getCurrentCameraArea(), 3) - getWord(sceneWindow2D.getCurrentCameraArea(), 1) + 1);
// Rounded font height for curent screen resolution
%font_height = mFloor(%this.lineHeight * %scale + 0.5);
// Adjusted line height of the current text object
%this.lineHeight = %font_height / %scale;
%this.removeAllFontSizes();
%this.addFontSize(%font_height);
}This code let me to get fine text objects for all screen resolutions. Is there different approach to show fonts correctly?
#13
11/12/2007 (2:06 am)
Thats a really nice little function Dmitriy, thanks for that. Did you get the email that I sent you?
#14
Excuse me for my silence. I didn't have any chance to reply you last weekend. I will mail you shortly.
11/12/2007 (3:10 am)
Thank you Phillip!Quote:
Did you get the email that I sent you?
Excuse me for my silence. I didn't have any chance to reply you last weekend. I will mail you shortly.
#15
My Text looks like a blob no matter what I try. I guess I don't understand how to properly use a text object.
Also, All the talk above abour Camera Size and Design Resolution seems odd to me.
I usually just set them both to be the same. If Im designing my game for 800x600 I just set the Camera to Match that. Would that be a problem for My text. That seems like the best way to avoid confusion on Units and Pixels. Just make 1 Camera unit = 1 pixel..
My main question is a simple way to drop my text in and it atcually look like text?
Edit: Used the AdjustSize Function Above... Solved the problem.
May just be me but .. What is the point of having the easy Drop in Text Object if it still requires script to make it appear readable?
01/20/2008 (2:00 pm)
I came across this post but am still having problems getting the Text Object to even be Somewhat Readable.My Text looks like a blob no matter what I try. I guess I don't understand how to properly use a text object.
Also, All the talk above abour Camera Size and Design Resolution seems odd to me.
I usually just set them both to be the same. If Im designing my game for 800x600 I just set the Camera to Match that. Would that be a problem for My text. That seems like the best way to avoid confusion on Units and Pixels. Just make 1 Camera unit = 1 pixel..
My main question is a simple way to drop my text in and it atcually look like text?
Edit: Used the AdjustSize Function Above... Solved the problem.
May just be me but .. What is the point of having the easy Drop in Text Object if it still requires script to make it appear readable?
#16
Try this and let us know what happens for you.
P.S. If you are doing something different such as loading this level into a second, smaller sceneGraph, you will have to fudge with the sizing.
01/20/2008 (4:30 pm)
It's readable for me. Click the "Text Edit Tool" on the toolbar, to the right of the selection tool. Then click someplace in the scene, and type something. Hello World works. For me the text is too big and I need to scale it down by changing the character height. I also use an 800x600 design resolution. Try this and let us know what happens for you.
P.S. If you are doing something different such as loading this level into a second, smaller sceneGraph, you will have to fudge with the sizing.
#17
Like I mentioned in my Edit above, I set the Text Class and used the function that Dmitriy posted and it makes the text crytal clear when I run the game. When I go back to the editor it is still Blurry and Blocky...
Also, What I was mentioning about the 800x600 was that I set My Camera Size to match my design resolution to make all my camera coordinates match the actual pixel size of my game. Just made more sense to me to think of everything in pixels instead of trying to always have a ratio for pixels to camera size...
I am not doing anything with the scenegraph.
01/21/2008 (3:05 pm)
I did have text typed in and could see it but it was extremly blurry and blocky no matter what size I set it at.Like I mentioned in my Edit above, I set the Text Class and used the function that Dmitriy posted and it makes the text crytal clear when I run the game. When I go back to the editor it is still Blurry and Blocky...
Also, What I was mentioning about the 800x600 was that I set My Camera Size to match my design resolution to make all my camera coordinates match the actual pixel size of my game. Just made more sense to me to think of everything in pixels instead of trying to always have a ratio for pixels to camera size...
I am not doing anything with the scenegraph.
Associate Phillip O'Shea
Violent Tulip
Your text objects have a default height of 10.0 units (or 80px). The actual font size they use is 72px, which means they get scaled down. If you want to change it, you can add other font sizes to your object.
For example:
This makes the text object use font size 16px (which corresponds to 2 units). To have it nice and smooth, just change the height of your text object to 2 units.
Just remember 1 unit = 8px and resize your text object to fit the font size you set and everything will be nice ;)