Game Development Community

Upgraded Scenes not working with TXB 2.0

by Paul Gower · in Torque X 2D · 03/24/2008 (1:09 pm) · 3 replies

I have a problem with some code that was working fine with TXB 1.0, that since has been upgraded to 2.0

I've been using:

StarterGame.Game.Instance.SceneLoader.UnloadLastScene();
// or StarterGame.Game.Instance.SceneLoader.Unload(@"data\levels\l" + old + ".txscene");

then..

StarterGame.Game.Instance.SceneLoader.Load(@"data\levels\l" + val + ".txscene");

to unload levels, and to load a new one, where val is the level number and old was the currently loaded level

Aside from a few objects that had to be unregistered, this worked fine with TXB 1.0. In TXB 2.0 however, using this just results in a blank screen (no errors, just blank!). Removing the .UnloadLastScene part gives me the two levels merged, as I would expect to see.

Any ideas why this would be happening or how to fix it? I ran into the >80 objects issue, which I fixed as described with the code below..

T2DSceneCamera cam = TorqueObjectDatabase.Instance.FindObject("Camera"); cam.FarDistance = 10000f;

I'm also calling SceneLoader from with a function inside the standard MovementComponent, which is attached to my player, which I then unregister, which is probably not the most genius idea. I had to change the type from T2DStaticSprite to T2DAnimatedSprite as it was barfing after the upgrade (it is an animated sprite, so I assumed I just made a typo before..)

About the author

Recent Threads


#1
03/25/2008 (7:11 pm)
I just ran into this problem myself today. It looked like the call to UnloadLastScene() wipes out the current sceneview along with everything in it. I ended up creating a new sceneview and then switching to it. I'll check my code and post it later, but it was something like this...

GuiSceneView newscene = new GuiSceneView();
GUICanvas.Instance.SetContentControl("GuiSceneView");

Again, I'll put together some real code, but it went something like this.

John K.
#2
03/26/2008 (11:45 am)
Hi John

Thanks for this.. I ended up doing the following (had to include GarageGames.Torque.GUI)

//create a renderable canvas for the scene
GUIStyle stylePlayGui = new GUIStyle();
GUISceneview playGui = new GUISceneview();
playGui.Style = stylePlayGui;

//switch over to the new canvas and load in the new scene
GUICanvas.Instance.SetContentControl(playGui);
StarterGame.Game.Instance.SceneLoader.Load(@"data\levels\l" + val

This worked for me, then I ran into the 80 objects problem which I tried to fix in the way described above, only to find that "Camera" no longer seems registered and so the search comes back null. In fact I couldn't find any camera's in use at all, so not sure what's going on there, or why I can see the screen in the first place!

So I tried to set the playGui object, since that has a Camera property..

playGui.Camera.FarDistance = 10000f;

And that also barfed because it's saying the object is read only.. any ideas how to work around that one?

Many thanks

Paul
#3
03/28/2008 (4:37 pm)
OK, fixed this now.. just needed to put the Camera code in the _OnRegister function ;-)