Text and ui samples
by Brandon Mckee · in Torque X 2D · 11/10/2007 (12:16 pm) · 2 replies
Are there any samples for on screen text or ui like buttons and menues?
About the author
#2
12/16/2007 (1:38 pm)
Now here is my question, say i make this text say game over or count how many lives the player has, where do i put these GUIText lines, and how do i implement them in the game? Do i have to put these in a seperate file and then referance them later or what? I dont understand this GUI thing at all, im used to the editor
Torque Owner rwillis
Here's how I made one of my buttons for my main menu:
GUIBitmapButtonStyle buttonStyle = new GUIBitmapButtonStyle(); buttonStyle.Focusable = true; buttonStyle.SizeToBitmap = true; buttonStyle.Anchor = AnchorFlags.All; GUIBitmapButton startButton = new GUIBitmapButton(); startButton.Style = buttonStyle; startButton.FocusOnWake = true; startButton.SelectedTexture = @"data\images\startHighlighted"; startButton.NormalTexture = @"data\images\start"; startButton.InputMap.BindAction(keyboardId, (int)Microsoft.Xna.Framework.Input.Keys.Enter, StartGame); startButton.Size = new SizeF(200, 50); startButton.Folder = this; startButton.Visible = true; startButton.Name = "startButton"; startButton.Position = new Vector2(412, 550);And here's how I made some Text:
GUITextStyle textStyle = new GUITextStyle(); textStyle.SizeToText = true; textStyle.FontType = "arial12"; textStyle.TextColor = Color.Black; textStyle.PreserveAspectRatio = false; textStyle.Anchor = AnchorFlags.All; textStyle.Alignment = TextAlignment.JustifyRight; GUIText enterFuelText = new GUIText(); enterFuelText.Visible = false; enterFuelText.Folder = sceneview; enterFuelText.Style = textStyle; enterFuelText.Position = new Vector2(512, 680); enterFuelText.Text = "Fuel load:";