GUIStyle does not contain a definition for Anchor
by Arris Ray · in Torque X 2D · 06/23/2008 (6:03 am) · 9 replies
I've hit a snag implementing the Airplane tutorial in the Torque X documentation. In the section describing the creation of a compass that remains statically positioned on the screen using a second GUISceneView, the tutorial refers to an Anchor property of the GUIStyle class.
GUIStyle InstrumentStyle = new GUIStyle();
InstrumentStyle.Anchor = AnchorFlags.All; // This line is trouble!
GUISceneview InstrumentView = new GUISceneview();
InstrumentView.Style = InstrumentStyle;
InstrumentView.Camera = InstrumentCam;
InstrumentView.NoRenderMask = instrument;
InstrumentView.Visible = true;
InstrumentView.Folder = WorldView;
Unfortunately, this property doesn't appear to exist anywhere in my Torque engine source code and attempting to compile throws the following errors:
error CS0117: 'GarageGames.Torque.GUI.GUIStyle' does not contain a definition for 'Anchor'
error CS0103: The name 'AnchorFlags' does not exist in the current context
Commenting the offending line out gives me an almost functional demo with my airplane flying fine against a tilemap of water and a bunch of Spawner ships. The compass appears on screen initially and rotates as expected but as the plane flies away from it, the main camera follows the plane and the compass scrolls off the screen.
Has the GUIStyle.Anchor property been silently deprecated or is there a preferred alternative to achieve the same functionality?
For reference, I am using Torque X 2.0.0/TXB and Visual Studio 2005.
Any help is greatly appreciated!
GUIStyle InstrumentStyle = new GUIStyle();
InstrumentStyle.Anchor = AnchorFlags.All; // This line is trouble!
GUISceneview InstrumentView = new GUISceneview();
InstrumentView.Style = InstrumentStyle;
InstrumentView.Camera = InstrumentCam;
InstrumentView.NoRenderMask = instrument;
InstrumentView.Visible = true;
InstrumentView.Folder = WorldView;
Unfortunately, this property doesn't appear to exist anywhere in my Torque engine source code and attempting to compile throws the following errors:
error CS0117: 'GarageGames.Torque.GUI.GUIStyle' does not contain a definition for 'Anchor'
error CS0103: The name 'AnchorFlags' does not exist in the current context
Commenting the offending line out gives me an almost functional demo with my airplane flying fine against a tilemap of water and a bunch of Spawner ships. The compass appears on screen initially and rotates as expected but as the plane flies away from it, the main camera follows the plane and the compass scrolls off the screen.
Has the GUIStyle.Anchor property been silently deprecated or is there a preferred alternative to achieve the same functionality?
For reference, I am using Torque X 2.0.0/TXB and Visual Studio 2005.
Any help is greatly appreciated!
#2
But this does raise another question: are there any updates available for the Torque X 2.0.0 tutorials or will any be forthcoming anytime soon?
06/23/2008 (7:22 pm)
Excellent, thanks for the pointer, Scott!But this does raise another question: are there any updates available for the Torque X 2.0.0 tutorials or will any be forthcoming anytime soon?
#3
I'm not sure about the tutorial documentation updates, though.
06/24/2008 (10:51 am)
Glad you found help on this!I'm not sure about the tutorial documentation updates, though.
#4
http://www.garagegames.com/blogs/44338/14528
Also there was some subsequent discussion and possibly some updates by Josef Rogovsky. You'll have to search the threads yourself ...
Not sure if the updates worked their way into the official distribution yet...
06/24/2008 (11:55 am)
I think John Kanalakis updated the tutorials (haven't tried them myself though). There at:http://www.garagegames.com/blogs/44338/14528
Also there was some subsequent discussion and possibly some updates by Josef Rogovsky. You'll have to search the threads yourself ...
Not sure if the updates worked their way into the official distribution yet...
#5
As a new Torque owner, I am quite impressed with the engine and even moreso with the community.
For any other folks who may be experiencing issues with the Airplane tutorial, John Kalanakis' tutorial updates do remedy the problem I described in the first post. Additionally, he shows how to work around another bug in Torque X v2.0.0, in which the NoRenderMask property of the GuiSceneview class simply doesn't appear to work.
Here is a link to a post by Josef Rogovsky (mentioned by Scott, above) where the Airplane 2.0 tutorial is discussed in a little more detail and which helped me to get my attempt at it up and running:
http://www.garagegames.com/mg/forums/result.thread.php?qt=73770
06/24/2008 (9:28 pm)
Again, thanks for the quick and insightful responses guys!As a new Torque owner, I am quite impressed with the engine and even moreso with the community.
For any other folks who may be experiencing issues with the Airplane tutorial, John Kalanakis' tutorial updates do remedy the problem I described in the first post. Additionally, he shows how to work around another bug in Torque X v2.0.0, in which the NoRenderMask property of the GuiSceneview class simply doesn't appear to work.
Here is a link to a post by Josef Rogovsky (mentioned by Scott, above) where the Airplane 2.0 tutorial is discussed in a little more detail and which helped me to get my attempt at it up and running:
http://www.garagegames.com/mg/forums/result.thread.php?qt=73770
#6
Additionally (I'm trying to get a text HUD element up), GUITextStyle.Color is listed as read only, so I can't set the color of the font (as written in the book). Any fix for this?
Thanks,
02/26/2009 (5:01 pm)
I'm using TX2 and I don't see definitions for either Anchor or HorizSizing or VertSizing, and I'm reading this from the book. Anyone have this happen to them?Additionally (I'm trying to get a text HUD element up), GUITextStyle.Color is listed as read only, so I can't set the color of the font (as written in the book). Any fix for this?
Thanks,
#7
I don't see a GUITextStyle.Color, but GUITextStyle.TextColor is a ColorCollection. As near as I can tell from the docs and demos the indexes of this collection correspond to the CustomColor enumeration.
Anyway, an index of 0 corresponds to CustomColor.ColorBase which allows you to set the text color for your GUIText items.
As for HorizSizing and VertSizing, I'm using them both on a GUIBitmap with no problem. They're inherited from GUIControl so they should be present on all the GUI controls.
02/27/2009 (11:44 pm)
@TalcottI don't see a GUITextStyle.Color, but GUITextStyle.TextColor is a ColorCollection. As near as I can tell from the docs and demos the indexes of this collection correspond to the CustomColor enumeration.
Anyway, an index of 0 corresponds to CustomColor.ColorBase which allows you to set the text color for your GUIText items.
// Sets text color to white style.TextColor[CustomColor.ColorBase] = Color.White;
As for HorizSizing and VertSizing, I'm using them both on a GUIBitmap with no problem. They're inherited from GUIControl so they should be present on all the GUI controls.
#8
03/02/2009 (7:11 am)
Right... I'm copying code directly out of the book from the chapter on adding text to the game screen. I'll try dereferencing the TextColor property. Still can't seem to find the VertSizing or HorizSizing properties, although I notice the book still refers to GUIStyle.Anchor- is the Complete Guide to TorqueX already out of date? I only bought it a couple months ago.
#9
03/05/2009 (10:22 am)
From what I've read TX Book is written for TX 3 so it's ahead of date.
Torque Owner Scott Goodwin
/// <summary> /// Defines how this control reacts when a parent control resizes. Defines /// the horizontal resizing options for this control. /// </summary> public HorizSizing HorizSizing { get { return _horizSizing; } set { _horizSizing = value; } } /// <summary> /// Defines how this control reacts when a parent control resizes. Defines /// the vertical resizing options for this control. /// </summary> public VertSizing VertSizing { get { return _vertSizing; } set { _vertSizing = value; } }in GUIControl with the options defined by:
public enum HorizSizing { /// <summary> /// The control will be fixed on the left side and in width. /// </summary> Right = 0, /// <summary> /// The control will be fixed on the left side and right side. /// </summary> Width, /// <summary> /// The control will be fixed on the right side and in width. /// </summary> Left, /// <summary> /// The control will stay centered horizontally to parent. /// </summary> Center, /// <summary> /// The control will resize relative to parent. /// </summary> Relative, } public enum VertSizing { /// <summary> /// The control will be fixed on the top side and in height. /// </summary> Bottom = 0, /// <summary> /// The control will be fixed on the top side and bottom side. /// </summary> Height, /// <summary> /// The control will be fixed on the bottom side and in height. /// </summary> Top, /// <summary> /// The control will stay centered vertically to parent. /// </summary> Center, /// <summary> /// The control will resize relative to parent. /// </summary> Relative, }