Game Development Community

Popdialog called and OnUpdateSceneTick for scenegraph still called

by Blake Drolson · in Torque Game Builder · 07/26/2010 (9:50 pm) · 3 replies

Hi there,

I noticed that after I call popdialog on a scenewindow, that the associated scenegraph onupdate function is still being called. I wonder if there is something I need to do to tell TGB that the scenegraph should go to sleep also.

More details... I create a lot of scenewindows and associated scenegraphs for all my menu screens, like this...

// CREDITS - Create scenegraph and window for the credits window that sits on top of the game windows
   ///////////////////////////////////////
   new t2dSceneWindow(creditsWindow2D);
   new t2dSceneGraph(t2dcreditsScene);
   creditsWindow2D.setCurrentCameraPosition("0 0", "800 600");
   // Associate Scenegraph(s) with Window(s).
   creditsWindow2D.setSceneGraph(t2dcreditsScene);   
   // now set up movemap for level select screen   
   new ActionMap(creditsMoveMap);   
   // do stuff to set up level select screen, set up movemap, populate with graphics, etc
   creditsWindow2D.SetUpCredits();

   // OPTIONS - Create scenegraph and window for the options window that sits on top of the game windows
   ///////////////////////////////////////
   new t2dSceneWindow(optionsWindow2D);
   new t2dSceneGraph(t2dOptionsScene);
   optionsWindow2D.setCurrentCameraPosition("0 0", "800 600");
   // Associate Scenegraph(s) with Window(s).
   optionsWindow2D.setSceneGraph(t2dOptionsScene);   
   // now set up movemap for level select screen   
   new ActionMap(optionsMoveMap);   
   // do stuff to set up level select screen, set up movemap, populate with graphics, etc
   optionsWindow2D.SetUpOptionsScreen();

Then I pop the dialog off doing something like ...
Canvas.popDialog(%guiToPop);

Thing is when I set breakpoints in the update scenecalls, they still get hit, even after being popped, like this...
function t2dcreditsScene::onUpdateSceneTick(%this)
{
   if (%this.pauseWeather == false)
      %this.MenuWeatherController.UpdateWeather();    
}

Any ideas on how I should arrange this, I don't want every menu screen update function being called no matter if its active or not.

Thank you in advance.

#1
07/27/2010 (12:31 am)
When you call the popDialog, the scene never ends, so its still updating itself. To stop the updating, just call the sceneWindows endLevel method
creditsWindow2D.endLevel();
the endLevel method will delete your t2dcreditScene and this should make it stop updating.
#2
07/27/2010 (2:44 am)
Thanks for the feedback William. Damn, I was hoping I could populate the scene and then when I needed it just push it onto the canvas. I guess I can just repopulate it everytime I need to push it back on the canvas.

There isn't anyway to make it pause updates when not current is there? I do notice a performance hit with all these scenes now in the background getting updated.
#3
07/31/2010 (4:36 am)
Just a quick update for anyone reading this thread later, I call %sg.endLevel() , and then %sg.delete(), works for me :).

I now delete the scenegraph when I pop its window off the canvas, then when I am about to push it back, I create it again and repopulate it. Its works , and I am surprised that it happens fast enough to not notice any delay.