Game Development Community

Some bugs in the tutorials

by Diego Ranzani · in Torque X 2D · 06/30/2008 (8:27 am) · 3 replies

Hi all,

I'm a indie and I'm starting using your great TorqueX 2.0 game engine but I've incurred in some bugs ( or at least I think they are bugs ) in your tutorials.

1) In the step 4 the following code doesn't work:

protected T2DSceneObject _GetUnit(Vector2 location, TorqueObjectType unitType)
{
List foundObjects = new List();
T2DSceneGraph.Instance.FindObjects(location, 1.0f, unitType, 0xFFFFFFFF, foundObjects);

if (foundObjects.Count == 1)
return foundObjects[0] as T2DSceneObject;
else
return null;
}

I was able to find a workaround using:

protected T2DSceneObject _GetUnit(Vector2 location, TorqueObjectType unitType)
{
List foundObjects = new List();
T2DSceneGraph sceneGraph = TorqueObjectDatabase.Instance.FindObject("DefaultSceneGraph");
sceneGraph.FindObjects(location, 1.0f, unitType, 0xFFFFFFFF, foundObjects);

if (foundObjects.Count == 1)
return foundObjects[0] as T2DSceneObject;
else
return null;
}

2) In the Airplane tutorial, step 6, the following code doesn't work:

TorqueObjectType instrument = TorqueObjectDatabase.Instance.GetObjectType("instrument");

T2DSceneCamera InstrumentCam = T2DSceneGraph.Instance.DefaultCamera.Clone() as T2DSceneCamera;
TorqueObjectDatabase.Instance.Register(InstrumentCam);

GUIStyle InstrumentStyle = new GUIStyle();
InstrumentStyle.Anchor = AnchorFlags.All;
GUISceneview InstrumentView = new GUISceneview();
InstrumentView.Style = InstrumentStyle;
InstrumentView.Camera = InstrumentCam;
InstrumentView.RenderMask = instrument;
InstrumentView.Visible = true;
InstrumentView.Folder = WorldView;

WorldView.NoRenderMask = instrument;

The Anchor property doesn't exist and this time I was unable to find a solution...

Can someone help me to complete the tutorial?

Thx,
Diego

About the author

Recent Threads


#1
06/30/2008 (9:21 am)
John Kanalakis produced updated tutorials...search his threads for the link. For point (2), AnchorFlags is deprecated...replaced by HorizSizing and VertSizing. Here's the revised code for step 6:
// create and register a camera for the compass
T2DSceneCamera DefaultCamera = TorqueObjectDatabase.Instance.FindObject("Camera");
if (DefaultCamera != null)
{
    T2DSceneCamera InstrumentCam = (T2DSceneCamera)DefaultCamera.Clone();
    TorqueObjectType instrument = TorqueObjectDatabase.Instance.GetObjectType("instrument");
    TorqueObjectDatabase.Instance.Register(InstrumentCam);
 
    // display the instrument camera on screen
    GUIStyle InstrumentStyle = new GUIStyle();
    GUISceneview InstrumentView = new GUISceneview();
    InstrumentView.Style = InstrumentStyle;
    InstrumentView.Camera = InstrumentCam;
    InstrumentView.RenderMask = instrument; // only render objects of type "instrument"
    InstrumentView.Visible = true;
    InstrumentView.Folder = WorldView;
    InstrumentView.Bounds = new GarageGames.Torque.MathUtil.RectangleF(0.0f, 0.0f, 1024.0f, 768.0f);
}
#2
06/30/2008 (10:30 am)
@Diego - Thanks for bringing this up. I've noted it to be changed in the official documentation. If you find anything else, feel free to post in the Official TorqueX Documentation Feedback Thread
#3
06/30/2008 (10:55 am)
Many thanks :),

I've found the link for the updated tutorials : http://www.garagegames.com/blogs/44338/14528

Bye,
Diego