Load scene in second camera?
by Stefan Sierder · in Torque X 2D · 09/01/2010 (9:55 pm) · 6 replies
hi community,
is it possible to have two cameras that display different .txscene files?
Idea is to have the GUI in one scene and the actual playscreen in another (since
this "playScreenCam" needs to allow scrolling without touching the GUI).
If it is not clear what i mean:

I think it is good to see on this pic, the frame starting on upperleft is the playscreen
which should be cam2 (scrollable) and the rest could be the default cam from txb.
is it possible to have two cameras that display different .txscene files?
Idea is to have the GUI in one scene and the actual playscreen in another (since
this "playScreenCam" needs to allow scrolling without touching the GUI).
If it is not clear what i mean:

I think it is good to see on this pic, the frame starting on upperleft is the playscreen
which should be cam2 (scrollable) and the rest could be the default cam from txb.
About the author
#2
find anything useful at the docs... am i missing something? Thanks in advantage.
not working code...
09/03/2010 (6:53 pm)
Thanks for the answer. Do you have any more information on this? I can'tfind anything useful at the docs... am i missing something? Thanks in advantage.
not working code...
public GuiStrategy()
{
GUISceneview mapScreen = new GUISceneview();
GUIStyle strategyStyle = new GUIStyle();
this.IsParentOf(mapScreen);
this.Name = "GUIPlay";
this.Style = strategyStyle;
this.Size = new Vector2(1280, 720);
mapScreen.Name = "StrategicMap";
mapScreen.Style = strategyStyle;
mapScreen.Size = new Vector2(128, 72);
T2DSceneCamera strategyCam = new T2DSceneCamera();
strategyCam.CenterPosition = new Vector2(0.0f, 0.0f);
strategyCam.Size = new Vector2(128.0f, 72.0f);
strategyCam.Visible = true;
strategyCam.Name = "StrategyCam";
TorqueObjectDatabase.Instance.Register(strategyCam);
mapScreen.Style = strategyStyle;
mapScreen.Camera = strategyCam;
...
#3
09/04/2010 (12:00 am)
Stefan your games looking nice.
#4
If you missed this undeground goodie i would give it a try, it's a really nice indie rpg.
Back to my question:
Has anybody a code sample how these two SceneViews work together and load different cameras and .txscene data as Mr. Perkins suggested? I just can't get it right, it always displays nothing (black screen).
09/04/2010 (1:32 pm)
actually thats "Eschalon's Book" from Basilisk Games, it's not my game but mine should look like this in the near future.If you missed this undeground goodie i would give it a try, it's a really nice indie rpg.
Back to my question:
Has anybody a code sample how these two SceneViews work together and load different cameras and .txscene data as Mr. Perkins suggested? I just can't get it right, it always displays nothing (black screen).
#5
09/04/2010 (5:31 pm)
I'm curious stefan, have you done the "Airplane Tutorial"? I highly suggest that first... Then work on your double scene loading idea. I understand wanting to load a separate scene because you want to be able to template all your GUI stuff probably? I'm sure you can.
#6
Theres a quick modification to the starter game that has two cameras overlapping.
The only code I changed was in the BeginRun method. I also added a second Torque logo to the default scene that is where the second camera is so that you can see that it works:
09/05/2010 (9:58 pm)
http://www.mediafire.com/?2ccgzeaote13iolTheres a quick modification to the starter game that has two cameras overlapping.
The only code I changed was in the BeginRun method. I also added a second Torque logo to the default scene that is where the second camera is so that you can see that it works:
protected override void BeginRun()
{
base.BeginRun();
// load our scene objects from XML. Torque X is designed to load game data from XML, but this is not strictly required;
// anything in an XML file can also be created manually in C# code. The SceneLoader is provided by TorqueGame and can be
// used to load and unload XML files.
SceneLoader.Load(@"data\levels\levelData.txscene");
T2DSceneCamera camera1 = new T2DSceneCamera();
camera1.Name = "Camera1";
camera1.Size = new Vector2(100,75);
camera1.Extent = new Vector2(100, 75);
T2DSceneCamera camera2 = new T2DSceneCamera();
camera2.Name = "Camera2";
camera2.Size = new Vector2(100, 75);
camera2.Extent = new Vector2(100, 75);
camera2.Position = new Vector2(200, 0);
TorqueObjectDatabase.Instance.Register(camera1);
TorqueObjectDatabase.Instance.Register(camera2);
GUISceneview scene1 = new GUISceneview();
scene1.Style = new GUIStyle();
scene1.Size = GUICanvas.Instance.Size;
scene1.Name = "Scene 1";
scene1.Camera = camera1;
GUISceneview scene2 = new GUISceneview();
scene2.Style = new GUIStyle();
scene2.Size = GUICanvas.Instance.Size;
scene2.Name = "Scene 2";
scene2.Camera = camera2;
scene2.Folder = scene1;
GUICanvas.Instance.SetContentControl(scene1);
}
Torque Owner Christopher Perkins