Game Development Community

Question: Passing information between scenes

by Kevin French · in Torque X 2D · 09/03/2010 (6:33 pm) · 6 replies

I was wondering if it is possible to pass information (in this case a list of strings) from one scene to another? Each scene is using a seperate scene view.

What I am trying to do is pass a list of creatures' names from the world scene to a battle scene. The battle scene and the world scene have their own GUIsceneview (I think that was the class). The world view has a list of possible creatures the player could face. The battle scene will display the creatures on the screen much like the old Dragon Warrior series did.

I've been trying and banging my head around to figure out how to do this with no luck so far. I believe Legends of the Rune Lords does something similar. Any pointers to a newb would be most appreciative.

#1
09/03/2010 (11:01 pm)
OK, either my question was clear enough or I'm going through some sort of forum hazing ritual :)

I'm still trying to figure it out on my own. If I come up with anything, I will post my results for the future newcomers to use.
#2
09/04/2010 (2:06 am)
Alright: Here is a code snippet of what I am trying to clone. The dijinTemplate is an object in the scene marked as a template with no components attached. This is my class constructor. I create the monster object from a called function right after I load the new battle scene.

public Monster(int xPos, int yPos)
 {
            T2DSceneObject Mob =  (T2DSceneObject)TorqueObjectDatabase.Instance.FindObject("dijinTemplate");
            mob = (T2DSceneObject)Mob.Clone();
            mob.Visible = true;
            mob.Position = new Vector2(xPos, yPos);
            mob.Name = "Dijin";
            mob.Layer = 0;
            TorqueObjectDatabase.Instance.Register(mob);
        }


Everything that I have read on the forums and docs suggest that I should be seeing my dijin at the specified location. Am I wrong in that assessment?

I have stepped through the code and an object is returned from the object database. It is a T2DStaticSprite.
#3
09/04/2010 (2:13 am)
Well, it is working after all!

I had the x coordinate to far for my camera window and the mob was rendering off screen. DUH!!!
#4
09/04/2010 (2:15 am)
That code looks good, However.. sometimes this can be tricky with multiple scenes, scene graphs and camera's.

One thing you may want to try is this
T2DSceneCamera cam = TorqueObjectDatabase.Instance.FindObject("Camera") as T2DSceneCamera;
            T2DSceneGraph graph = cam.SceneGraph as T2DSceneGraph;
            foreach (T2DSceneObject obj in TorqueObjectDatabase.Instance.FindObjects<T2DSceneObject>())
            {
                obj.SceneGraph = graph;
            }

Call this function each time you load a new scene, and see if this makes a difference. This is actually a bug I'm dealing with right now, TorqueX wants to load multiple scenes, but it needs your help to do it!

#5
09/05/2010 (2:20 am)
Thanks for the heads up on loading multiple scenes. I did get my stuff working. It was just a matter of understanding how TX views the width and height of the camera. I thought it was 0,0 top left corner to height and width. Turns out, 0,0 is in the center of the camera's view. Please, correct me if I am wrong.
#6
01/02/2017 (2:36 am)
Trying to find the Famous Kevin French of tmmokit fame and torque game engine expert.... vikingchain@yahoo.com if you're still out there in tv land.