Game Development Community

Black screne after mounting camera?

by Drethon · in Torque X 2D · 06/10/2009 (3:46 pm) · 3 replies

I mounted the camera to a sprite based on the Airplane tutorial and now when I run the game the screne is completely blank. What did I miss?

In case its helpful, here is my hacked in code:

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\Untitled.txscene");

            T2DSceneObject _player =
             TorqueObjectDatabase.Instance.FindObject<T2DSceneObject>("PlayerShip");

            T2DSceneCamera SceneCamera = new T2DSceneCamera();
            SceneCamera.CenterPosition = new Vector2(0.0f, 0.0f);
            SceneCamera.Extent = new Vector2(100.0f, 75.0f);
            TorqueObjectDatabase.Instance.Register(SceneCamera);
            TorqueObjectType mainCamera = TorqueObjectDatabase.Instance.GetObjectType("mainCamera");
         
             //ignore the rotation 
            SceneCamera.TrackMountRotation = false;

            SceneCamera.Mount(_player, "", false);

              //display the camera on screen
            GUIStyle WorldStyle = new GUIStyle();
            GUISceneview WorldView = new GUISceneview();
            WorldView.Style = WorldStyle;
            WorldView.Camera = SceneCamera;
            WorldView.RenderMask = mainCamera; // only render objects of type "mainCamera"
            GUICanvas.Instance.SetContentControl(WorldView);
        }

#1
06/11/2009 (11:02 pm)
Drethon, when the camera is not mounted, is there still a black screen or does it work properly then?

John K.
www.envygames.com
#2
06/12/2009 (9:20 am)
Add "mainCamera" object type to the water background and the ship templates first. The tutorial forgot to mention that.
#3
06/15/2009 (9:37 am)
Yeah the screen was fine before the mount, I'll try your suggestion Miguel. Sorry for the delay, finals are going on so I'm kinda shut down for a little bit...