Game Development Community

Newbie TGB Question about Level and Scene Switching

by Chris "Hyena" Vogel · in Torque Game Builder · 08/12/2009 (2:01 am) · 3 replies

Hello everyone,

I've once again picked up TGB again and I'm trying to relearn it. I have a solid game design that I'm just starting on, and I find that I don't remember much of anything about how to use TGB or TS.

So, I have a simple question.. I wasn't able to find this in the documentation, but I'm sure it's out there. Hopefully you can point me in the right direction.

My game is going to have quite a few 'screens' or 'scenes' that will pretty frequently be switched back and forth. stuff like a char creation screen, an inventory screen, a combat screen.

I was going to build each of these screens as a T2D Scene file. Is that the best way to go? If I have character info in a scene, is it any problem to move that from one scene to another? Should I be using GUI elements for this instead? Assuming my design with using different scenes will work, then,

How do you switch from one scene to the next?

#1
08/12/2009 (9:15 am)
The standard way to switch between scenes is something like, SceneWindow2D.schedule(20, "loadLevel", "game/data/levels/NewLevelHere.t2d"). This closes your old scene and loads the new one. As for your design question, it really depends on your game but I would expect that having each screen as a separate scene would be the simplest approach. I believe that you'll have to use global variables to store and information that you want to transfer between scenes. Of course, I'm pretty inexperienced at this and there might be a better approach that I don't know about.
#2
08/12/2009 (8:40 pm)
Thanks Nate, that helped. My plan is working well so far, but I have one worry...


Is it ok to have a large # of .t2d scene files in a project, will this effect performance? It seems to be working great for me now. A lot of my project is basically a menu-driven 'choose your path' type of thing, and each 'page' i'm doing now as a new scene. I might have 50 or so scenes that will be switched back and forth fairy regularly when all is done.

Does anyone see that as being a problem?

I could probably accomplish all this by learning the GUI system, too... But if this works the way I'm doing it, I'll stick with it.
#3
08/13/2009 (6:26 am)
i dont see it as a problem... but you must make sure that the graphics that are contained (referenced) in each level, are loaded onto memory most of the time, so there wont be any notticeable lag or whatever.