The Daily Click ::. Forums ::. Klik Coding Help ::. how to pause a game!
 

Post Reply  Post Oekaki 
 

Posted By Message

J.R.P



Registered
  16/08/2007
Points
  384
4th March, 2008 at 07:46:54 -

i wanna know how you make your game pause by pressing a key and not by going to the crappy menu option up the window! this is what i had in mind: pressing the enter key makes game pause then by pressing the same key again it will make the frickin game unpause! Thanks for your time clickers!

 
That there is one damn fine coat your wearin.

-Nick-

Possibly Insane

Registered
  24/11/2002
Points
  2468

VIP Member
4th March, 2008 at 07:50:36 -

Personally, i put all my "game" events in one big group and "pause" events in another. Disable the game group when paused, and enable it when unpaused. Don't forget to stop and start your animations though! This could cause problems if you use MMF movements, but i've never tried it.

 
Project: Roller Coaster is on it's way!
http://www.projectrollercoaster.co.uk/
http://www.craftsncreatures.com

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
4th March, 2008 at 09:54:24 -

Are you using TGF, MMF1.5, TGF2 or MMF2?

If it's MMF1.5 or 2.0, you can create a subapp object. It basically displays a level within a level (you use them to create splitscreen games, for instance).

You create a separate menu frame, and then (in your playable level) create a subapp. In its properties, assign the subapp to use frame number [your menu frame number] from 'this application'.

There should be a toggle box that says 'Modal' in the properties as well. Tick it.

Now create an event which says:

ON ESCAPE PRESSED
--- Create Object: Subapp Object at (0,0)

Once you've created this, DELETE your original subapp object from the frame (important). So long as there's a 'create object' event pointing to the subapp, it will not be totally deleted. It just won't be created at the start of the frame (otherwise your game would start with the menu showing up. And having the menu displayed in the frame editor as you design the level is a nuissance anyway).

Now, in the MENU frame, add this action:

ON ESCAPE PRESSED
+Timer is greater than 2/100ths of a second
--- End the Application

This will close the menu again when you press escape a second time.

Note that a subapp thinks it's a completely separate application. So 'End the application' only closes the subapp, not the whole game.

You can tick the 'share global values and strings' option in the subapp object to allow the subapp menu to communicate with the rest of the game. This needs to be done, for instance if you want a feature like a 'QUIT' button.

This solution works very well because of that 'MODAL' setting we used above. This innately pauses the game while it runs the subapp. When the subapp closes, the game resumes.

 
191 / 9999 * 7 + 191 * 7

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
4th March, 2008 at 11:22:37 -

Thats certainly a good workaround dines. I've always manually waded in like nick's method; activate/deactivate event groups and stop animations. However, using subapps it could be potentially complicated to pass data back and forth from the menu to the game. Its quite possible, you just need to have a very good handle one what you are doing.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

nim



Registered
  17/05/2002
Points
  7234
4th March, 2008 at 17:25:33 -

Dines, you're a genius. What does "Modal" mean, though?

Image Edited by the Author.

 
//

J.R.P



Registered
  16/08/2007
Points
  384
5th March, 2008 at 03:30:46 -

Thanks for the help everyone
deadmandines: thanks, all that info was helpful!

 
That there is one damn fine coat your wearin.

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
5th March, 2008 at 15:20:12 -

I'm not sure what the term 'Modal' means, but what it DOES is thus:

It pauses the parent application while its child window runs. So like thos programs where an error message pops up, and you can't just minimise the error message and carry on working. You have to click OK or CANCEL before you can carry on working.

Such error messages are Modal.

In the case of a subapp as a menu, this just works in our favour because it automatically pauses the game running underneath.

 
191 / 9999 * 7 + 191 * 7

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
5th March, 2008 at 15:49:19 -


Originally Posted by DeadmanDines
I'm not sure what the term 'Modal' means, but what it DOES is thus:

It pauses the parent application while its child window runs. So like thos programs where an error message pops up, and you can't just minimise the error message and carry on working. You have to click OK or CANCEL before you can carry on working.

Such error messages are Modal.

In the case of a subapp as a menu, this just works in our favour because it automatically pauses the game running underneath.



In Visual Basic 6 you could create Modules to go with your main program which were these little offshoots of code. I never really had much use for them aside from maybe one at the beginning that initialized everything.

I've always used the activate / deactivate method myself. Dines is probably doing it the "right" way though.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Eternal Man [EE]

Pitied the FOO

Registered
  18/01/2007
Points
  2955

Game of the Week WinnerHero of TimeLOL SignI am an April Fool
5th March, 2008 at 22:28:35 -

I personally use the activate/deactivate method, it's extremely easy and stable + values don't need to be global. About the subapp method, say you wan't to change objects positions and such in realtime, is that possible or is the game frozen until menu is exited?

 
Eternal Entertainment's Code'n'Art Man

E_E = All Indie


...actually Ell Endie, but whatever.
Image
Image
   

Post Reply



 



Advertisement

Worth A Click