Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
:/
>Create an object, and name it objPause
>Select "Add Event", select "Key Press", and then select the button you want to pause with
>Go to the control tab and add an action of "Code Execute"
>Insert this code(lines with // before text indicates a comment explaining what the code does)
{
draw_set_color(c_red) //Sets the color that the text will be drawn as to red
draw_set_halign(fa_center) //Sets the text to draw horizontally centred
draw_text(room_width/2,room_height/2,"Game Paused") //Draw's the text in the centre of the room
screen_refresh(); //Refreshes the screen so the text is drawn
io_clear(); //Clears the keyboard's state
keyboard_wait(); //Waits for the users to take pause off
}
>Save the object and close.
>Test.
:)
Hopefully it works how you want it to.
Good luck with your game!
:/
Sorry about that.
They've put this limitation on so, as most companies do, you'll be getting somewhere, and then suddenly you can't go any further.
:|
It does get frustrating.
The method that terraformer299 pointed out is pretty good, except it's limited to pausing absolutely everything or pausing absolutely nothing. There is no inbetween, and you may not want to pause everything all the time. For example, you might want a game that allows the player to bring up an inventory that can be controlled while everything else is paused. In most cases you'd want enemies and whatnot to be paused while you are free to equip/unequip items and such. This sort of "pausing" is also useful for RPGs and other games that use text boxes and have cutscenes and such. In those cases, you will want to freeze most objects and events except for certain character movements and dialogue.
HOW TO DO IT:
To do this method of pausing, you would need to create a variable that keeps track of the paused status (you could also have different levels of paused status, which can be very useful).
Before executing movement and most any code, you would simply have it check if the game is paused by checking the value of the pause variable, and have it exit the script if the game is paused.
The problem with this is that you need to build your game from the ground up with this in mind, or you will likely have much difficulty reprogramming a project to make use of this method, and you may not be able to use a lot of the motion drag and drops. Learning to program step-by-step movement is practically required for this method, which means much more work.
This is mildly advanced stuff, but it really pays off to push yourself to learn new, better methods.
------------------------------------------------------------------------------
Code example for a GML script:
------------------------------------------------------------------------------
// any code placed here will execute, regardless of the paused value
if pause = true{
exit;
}
// any code placed here will only execute if paused = false (if the game is not paused)
------------------------------------------------------------------------------
You may also use numbers (as opposed to just true/false) if you want to have various levels of paused status for more control. Meaning "0" is not paused at all, "1" is inventory only, and "2" is cutscene which does not allow you to even enter into your inventory (for lack of a better example).
Best of luck to you!
EDIT: It also allows exacting control over the pause, and unlike terraformer's method, allows a working pause screen, since input doesn't resume the game.
EDIT2: You might be able to do it in D&D, just "Check if variable pause is set to true", "Start a block of code" (or whatever it's called), "Exit event", "End code block", rest of code.
Don't quote me on that. I don't use D&D, really.
Create event for button to signal pause.
Check current room, if not Pause room
record current room
Change to pause room
Else
Change to "previous" room. Can be trick as it's not actually the previous room drag and drop option.
Also not to say mine is any more right, but mine contains at least some of the basic logic for handling a title screen, that you can escape to, and then resume from. Or at least I think so :-)
Still probably would look at doing FrozenFires suggestion myself at some point as I do kinda want to do one of those pause menus that appear over the game. Which is fun if you want to try the drag and drop approach. Hit P, save screen shot, load screenshot as background, change the pause room background to screen shot, go to pause room. Handle all the pausing stuff in there as well.
FrozenFire's. Parent class the objects, with pause build in and then use a controller to detect pause and display pause sprite over the top. Bleh, why do I get a sinking feeling my project is duff and I'm going to have scrap and start again. Ah the fun of learning new programming.
If you want to KEEP the parent's code AND add new code, you have to add "event_inherited()" at the top of the Step event for the object you set to have that parent.
The tutorials don't really go into that much detail parent objects or at least so far that I've got.
I got so far through the tutorials and though hmm with this one I could add so much more. Is there a detailed scripting tutorial?