Text Alignment Problem [SOLVED]
by Aesielle Ehrhart · in Torque X 2D · 03/06/2010 (9:51 am) · 2 replies
I am trying to display on a screen high score information. I have the scores and the player's names showing up just fine, but I want to 'Right-Align' the scores being displayed. I have set my GUITextStyle to TextAlignment.JustifyRight, but this doesn't seem to have any effect. I have tried many different combos of changing other aspects of the GUITextStyle, but nothing seems to work. Does anyone know what I might be missing (it seems rather straight forward but. . .) Here is my code (at least the relevant part):
GUIStyle stylePlayGui = new GUIStyle();
GUISceneview playGui = new GUISceneview();
playGui.Style = stylePlayGui;
// Style for the names
GUITextStyle textStyle = new GUITextStyle();
textStyle.FontType = @"datafontsJunegull";
textStyle.TextColor[0] = Color.Black;
textStyle.SizeToText = true;
textStyle.PreserveAspectRatio = true;
textStyle.Alignment = TextAlignment.JustifyLeft;
// Style for the scores
GUITextStyle numStyle = new GUITextStyle();
numStyle.FontType = @"datafontsJunegull";
numStyle.TextColor[0] = Color.Black;
numStyle.SizeToText = true;
numStyle.PreserveAspectRatio = true;
numStyle.Alignment = TextAlignment.JustifyRight;
// Top high score
GUIText PuzOneNum = new GUIText();
PuzOneNum.Style = numStyle;
PuzOneNum.Position = new Vector2(NumPX, PYO + (PYA * 0));
PuzOneNum.Layer = 0;
PuzOneNum.Visible = true;
PuzOneNum.Folder = playGui;
PuzOneNum.Text = highScores.PuzScore[9].ToString();
GUIStyle stylePlayGui = new GUIStyle();
GUISceneview playGui = new GUISceneview();
playGui.Style = stylePlayGui;
// Style for the names
GUITextStyle textStyle = new GUITextStyle();
textStyle.FontType = @"datafontsJunegull";
textStyle.TextColor[0] = Color.Black;
textStyle.SizeToText = true;
textStyle.PreserveAspectRatio = true;
textStyle.Alignment = TextAlignment.JustifyLeft;
// Style for the scores
GUITextStyle numStyle = new GUITextStyle();
numStyle.FontType = @"datafontsJunegull";
numStyle.TextColor[0] = Color.Black;
numStyle.SizeToText = true;
numStyle.PreserveAspectRatio = true;
numStyle.Alignment = TextAlignment.JustifyRight;
// Top high score
GUIText PuzOneNum = new GUIText();
PuzOneNum.Style = numStyle;
PuzOneNum.Position = new Vector2(NumPX, PYO + (PYA * 0));
PuzOneNum.Layer = 0;
PuzOneNum.Visible = true;
PuzOneNum.Folder = playGui;
PuzOneNum.Text = highScores.PuzScore[9].ToString();
About the author
Recent Threads
#2
03/06/2010 (11:43 am)
Cool, after a bit of tweaking I got that to work! I knew I just wasn't understanding something. Thank you very much!
Torque Owner Scott Cameron
if you want to align the text on the screen you need to set thier position properties to something that lines them up.
in this case you would want all thier Position.X properties to be the same value. and increase the .Y value according to the spacing you want going down the column.