Pausing a game
by rwillis · in Torque X 2D · 05/06/2007 (8:31 pm) · 5 replies
I created a game using XNA and the way I paused it was to just do it in the update and draw methods. Now i'm porting that game over to torque X and I'm not sure how to go about pausing it. Can I get some ways other people are doing it?
About the author
#2
05/08/2007 (12:50 pm)
Jason is correct, just do it in the Update method. You actually can call an XNA property to throttle the entire game down as well, but I can't remember the property off the top of my head. Something to look for though.
#3
But to get this to work in pausing the game I think I have to use bindAction (because if i set GameTimeScale in processTick using my Pause method, then I'm unable to unpause it because the processTick is no longer updating, hence the pause in time). The end parameter of bindAction takes in a delegate, which is created using something like InputMap.ActionDelegate.CreateDelegate. Anyone know how to use this create delegate method?
BTW, I tried to change GameTimeScale in an overrided update method in the main game class, but for some reason the game goes extremely slow when the update checks for i.e. keyboard.isDown(Keys.p), so it seems like it didn't work.
05/08/2007 (5:54 pm)
Thanks. I found TorqueGameEngine.Instance.GameTimeScalewhich also seems to work.
But to get this to work in pausing the game I think I have to use bindAction (because if i set GameTimeScale in processTick using my Pause method, then I'm unable to unpause it because the processTick is no longer updating, hence the pause in time). The end parameter of bindAction takes in a delegate, which is created using something like InputMap.ActionDelegate.CreateDelegate. Anyone know how to use this create delegate method?
BTW, I tried to change GameTimeScale in an overrided update method in the main game class, but for some reason the game goes extremely slow when the update checks for i.e. keyboard.isDown(Keys.p), so it seems like it didn't work.
#4
05/09/2007 (7:55 am)
I wouldn't change the gametimescale for reasons you are already finding. If you slow the ticks way down, then it wont respond immediately to you hitting a button or whatever to unpause. What you'll want to do is do a check in the update function that basically skips everything you are doing and override the draw functionality to stop drawing to the screen.
#5
warkittensoftware.com/blog/2009/01/10/timeout-pausing-the-game/
11/29/2009 (12:57 am)
I found this pretty helpful:warkittensoftware.com/blog/2009/01/10/timeout-pausing-the-game/
Torque Owner Jason Swearingen
From the Game class (which inherits from TorqueGame) try to override the Update and Draw methods