Using two scenegraphs??
by Kevin Epps · in Torque Game Builder · 08/11/2008 (5:49 pm) · 24 replies
Is there a way to use two scenegraphs and have them overlap each other? I know I've seen someone talk about it before, but, dammit, I can't find it. I hate that!!!
Anyway,
I'm trying to load a level inside of another scenegraph and display over the default scenegraph.
How the heck do I do it?
Anyway,
I'm trying to load a level inside of another scenegraph and display over the default scenegraph.
How the heck do I do it?
#2
Thanks. : )
08/12/2008 (12:12 am)
Would you care to share how to do it? I'm thinking about doing the same here..Thanks. : )
#3
If you wanted to say, do an ingame continue screen, you could do the same thing by putting this before the previous code:
And there you go!
This is a very cool feature. I love it.
08/12/2008 (5:50 am)
No problem!// Find the canvas content
%mainScreen = Canvas.getContent();
// Create a new window to load new scenegraph in
%sceneWindow = new t2dSceneWindow(window_test)
{
// Position and size
Position = "0 0";
Extent = %mainScreen.getExtent();
// Ensure it always covers the entire window
HorizSizing = "WIDTH";
VertSizing = "HEIGHT";
};
new t2dSceneGraph(Sassafrass);
Sassafrass.loadLevel("game/data/levels/test_hud.t2d");
window_test.setSceneGraph(Sassafrass);
%mainScreen.add(%sceneWindow);If you wanted to say, do an ingame continue screen, you could do the same thing by putting this before the previous code:
//Graph the main game's scenegraph before even trying to do this, so you can switch back. $mainSceneGraph = sceneWindow2D.getSceneGraph() //Pause all objects on main game's scenegraph $mainSceneGraph.setScenePause(true);
And there you go!
This is a very cool feature. I love it.
#4
08/12/2008 (1:57 pm)
There is a lot you can do with multiple scenegraphs and scenewindows ;) I made a lot of nifty effects and widgets with this feature.
#5
08/14/2008 (12:35 am)
That's great Kevin, thanks! Like your choice of scenegraph names. :)
#6
thx guys...
08/17/2008 (10:26 pm)
Thats the info i was looking for... now i can use easily my custom menus on my game... i still cant get a hold of the GUI system, so i just use the MainScreen GUI template... the other ones, i better not... but with this lil bit of code, i can do the rest easily...thx guys...
#7
08/17/2008 (10:40 pm)
The Parallax Layer method uploaded in the PSK's TDN page takes advantage of multiple scene windows and graphs. It is a pretty nifty little feature ;)
#8
08/18/2008 (5:49 am)
Yep! That's where I figured out how to use it from!
#9
Can somebody give me an example or situation where I should / must use two or more scenegraphs?
Thanks
08/18/2008 (8:55 am)
Why should somebody use two scenegraphs to make a menu if everything will be handled in a single scenegraph using multiple objects?Can somebody give me an example or situation where I should / must use two or more scenegraphs?
Thanks
#10
08/18/2008 (9:10 am)
If one scenegraph contains all your "game" sceneObjects and camera moves are done on that scenegraph, you might want another scenegraph overlayed that one (which you do not do camera moves on) to contain sceneObjects that represent gui elements (rather than using actual guiControls).
#12
I have two examples. SceneObject based healthbars and scrolling old school RPG-style dialog texts. I basically have objects scroll in and out of the little windows, obscuring and uncovering texts or other sprites to give the desired effect. These methods wouldn't have worked without multiple scenegraphs.
08/18/2008 (8:48 pm)
@IsaacI have two examples. SceneObject based healthbars and scrolling old school RPG-style dialog texts. I basically have objects scroll in and out of the little windows, obscuring and uncovering texts or other sprites to give the desired effect. These methods wouldn't have worked without multiple scenegraphs.
#13
Thanks for the examples. That's more clear for me now. Now I have this knowledge for future reference.
08/19/2008 (8:16 am)
@Joe,Thanks for the examples. That's more clear for me now. Now I have this knowledge for future reference.
#14
lemme put it this way:
i have a main menu with all its buttons and shit, right?... when i click on the "how to play" button, it should open a new GUI showin instructions on how to play the game, while showing the original animation of the main menu.
whenever i close that "how to play" GUI, i cannot click on the main menu buttons anymore...
question is, how do i enable back the main scene, so i can keep goin interactin with it?.. i've read the SDK dox about the commands on the T2DSceneWindow and T2DSceneGraph, and dont see one that really works for what im looking for... so, help anyone?
thank you in advance.
EDIT: nevermind... i've figured it out!!... here goes, for the ones who dont know the answer yet:
im gonna use the exmple above...
with that single line, you can go back to the original SceneGraph you were workin on, and so far, it has not given me any troubles.
08/26/2008 (6:40 pm)
I've been thinkerin with this technique some, and while it works flawlesly when loading a new GUI and all, whenever i try to unload it and work with the "old" scenegraph, it just doesnt work!... lemme put it this way:
i have a main menu with all its buttons and shit, right?... when i click on the "how to play" button, it should open a new GUI showin instructions on how to play the game, while showing the original animation of the main menu.
whenever i close that "how to play" GUI, i cannot click on the main menu buttons anymore...
question is, how do i enable back the main scene, so i can keep goin interactin with it?.. i've read the SDK dox about the commands on the T2DSceneWindow and T2DSceneGraph, and dont see one that really works for what im looking for... so, help anyone?
thank you in advance.
EDIT: nevermind... i've figured it out!!... here goes, for the ones who dont know the answer yet:
im gonna use the exmple above...
window_test.delete(); //window_test is the name of the given new window...
with that single line, you can go back to the original SceneGraph you were workin on, and so far, it has not given me any troubles.
#15
08/26/2008 (8:28 pm)
Possibly just setting it not visible would also keep it from processing mouse input "window_test.setVisible(false)", or there might be a clever way to allow mouse input to pass through your empty top layer sceneWindow into the lower one.
#17
08/26/2008 (9:39 pm)
That's what i do and it works ;)
#18
how can i create it, so i can interact with it at a given time?...
08/26/2008 (11:01 pm)
Ok... i used it, and yeah, it worked... i didnt really need to delete the new window/scenegraph for it to dissapear from my face (and since its already created, i kinda save some CPU cicles)... problem is, i created some kinda menu in that new window, and theres a button that allows me to close it... but whenever i try to click on it, NOTHING HAPPENS!... its like the new window is active but its not at the same time... how can i create it, so i can interact with it at a given time?...
#19
// makes it visible
window_test.setVisible(true);
// makes it not-visible
window_test.setVisible(false);
08/26/2008 (11:41 pm)
Uhh, maybe you are asking something more complex, but shouldn't this be all you need?// makes it visible
window_test.setVisible(true);
// makes it not-visible
window_test.setVisible(false);
#20
08/28/2008 (7:28 am)
Whenever i create the window, it shows up, and i can make it appear and dissappear with the commands that you stated above (and the old scene gets the focus when i make it dissapear, like intended), but i've created a button on that window, and it seems all its properties are ok, but whenever i try to click on it... NOTHING HAPPENS!.. so, maybe something is wrong... but i cant figure out what is it.
Torque Owner Kevin Epps