answering the question before it shows up, if your room is bigger than your view you want to use view_xview and view_yview instead of room_width and room_height. Great tut
[resolved] When I replace those two, it didn't work. Could you elaborate? (the following writes the text in the top left (no black rectangle)) ----------------------------------------------------------------- if (global.pause) { draw_set_color(c_black); draw_set_alpha(0.5); draw_rectangle(0,0,view_xview ,view_yview ,0); draw_set_halign(fa_center); draw_set_font(fnt_prn3); draw_set_color(c_yellow); draw_set_alpha(1); draw_text(view_xview /2,view_yview /2,"Connection Paused"); draw_set_color(c_black); }
I understand that this video is very old, but I still found it useful and I'm sure others do as well. A quick tip for the issue regarding alarms, instead of using GM:S' built in alarms you can make your own by running setting a global variable (I use global.timer_x where x is a number to separate unique timers) to the value you would set your alarm and just have the global variable decrease by 1 in the step event of the object its related to and have your code run once it hits 0, that way when you exit out of the objects step event it also pauses you alarms/timers. (You can also use local variables if the alarm only affects the one object it's attached to, but I would recommend setting global variables in you game initialization just to make things easier to work with and having all your eggs in one basket kind of thing)
Thanks for this, it is a very simple but useful insight. I'm looking forward for better implementations (maybe more complete/straightforward) and a possible actual menu on pausing. Love your videos, keep up the good work as always.
Out of all the methods I've tried, this one just seems to work the best, which is convenient because of how straight forward it is. Alarms can be a problem, but making "custom" or kind of "homemade" alarms in step events is an easy solution, and is still simpler than other methods I've used.
ok then... if ya say so *cough**cough* Steve Vautour 8 months ago @ Destro700 Is your room bigger than your view? Use something like this: draw_text(view_xview[view_current] + view_wview[view_current] / 2, view_yview[view_current] + view_hview[view_current] / 2, "PAUSED");;des i found it ! ahem
That's really a nice idea to create a pause system in a game. On the other hand, working this way involves dealing with controls checking, objects movement, collision checking and on all in the step event; btw I think I'll redefine my games with this new knowledge...
Nice pause work :) If you want to manage your loads, exit the game in the pause menu, I recommend creating objects like obj_exit or obj_load on obj_pause's step event in if (global.pause == 1) {instance.create(yourstuffs)} and then add a left click event to use a load script (as shown on Shaun in early tutorials) or exit the game. This way to pause a menu is a bit tricking the computer because in fact in just freeze ennemies and player but it works well on little games so thank you Shaun.
Alarm system is just an array. When starting pause copy all `alarm` values to `my_paused_alarms` and set every alarm to -1, when resuming copy back from `my_paused_alarms` to `alarm`. Or don't bother with alarm system at all, decrement counters in step event, you will get better naming. 3 days later variable `next_boss_phase_counter` makes much more sense than `alarm[5]`.
5.24 after doing this, my screen darkened but no text showed up (even after quickly adding a font set as Arial) why is my text not showing up? Also 8:00 I added [if (global.pause) exit;] (without brackets) to my obj_Enemy's step event and it didn't stop it at all. The background dimming action works though!
It's possible with that system to have not errors with timers. In every frame if pause you easily can add one frame to all your timers. example: if (global.pause) { alarm[0] ++ or +=1 exit; } and that for every Timer :D
***** Yes and no I think, I just created this same pause system for my game weeks ago and did the += 1 thing on all timers and I ran into that issue of pausing at the worst frame. But you should be able to circumvent that issue easily by saying "if alarm[] < 0 alarm[] +=1" this way it only pauses the alarms if its active.
***** Okay come on, we're programmers here: if global.pause && alarm[0] > 0{alarm[0] += 1;} If an alarm has already hit -1, then it's essentially executing the code, assuming someone paused on that point (for this example let's say something would be created when the alarm went off), the object would be created and should then in turn notice that the pause variable was set to true. This would then pause that object. Let's be realistic, it's almost impossible for a player who isn't looking very very hard to spot that one step difference. And now that I read ahead it seems someone already beat me to it. Matthew Lemmel
***** I use a very similar pause system approach in my game. To solve the alarm issue, at the moment the game gets paused, I looped through every pausable object, stored all of their alarm values into an array, as well as the instance's id. Then set their alarm's value to 0 to deactivate the alarm. Then when I unpause the game, I simply looped through the array and restored the alarm's value. It has worked very well. I do the exact same thing for every object's gravity, hspeed, vspeed, image_speed and path_speed
Nice video. I look forward to seeing the next tutorial in the series. I've got a few comments. 1. You might have just been doing it your way to keep the code easier to understand but at 2:00 you could have done global.pause= 1-global.pause, or if you were using booleans (and in this case you are because of the way game maker variables work) global.pause=! global.pause is also valid 2. I've used this technique before and I've come across an issue with parenting. So let's say the parent has if(global.pause) exit; in the step event and I have a step event in the child using event_inherited() to manually inherit the step from the parent. When event_inherited() is called the event of the parent is exited but the rest of the code in the child step event still runs. I guess the solution is to copy the code over to everything, but it's frustrating that parenting can't be used.
Whenever I use the pause feature the draw takes place below all of my other objects, so none of the characters are tinted grey and the pause text is often obsured by the level environment. :( Please help :P
if i press pause, the overlay appears. But my object (with gravity) falls, how do i make it stop. Is there a code to put in extra? Thankyou so much for this video btw!!!
Use a global variable to hold the gravity value, set your gravity for your "object" to zero (0) in your if-else for your pause, when the player presses escape again, set the gravity of your "object" to the global variable. I'd recommend making your own global variable for your gravity vs using the Game Maker predefined Gravity. Could cause problems.
I have a problem, I don't have the movement or collision in the step event for my player, and I also don't have a step event for another object that changes sub-image every second (It does that automatically) and so the pause does not stop anything. Where would I put the code for stopping things? All of the movement and collisions are frag and drop.
Oh I got it from another comment! Hopefully this works! draw_text(view_xview + view_wport / 2 ,view_yview + view_hport / 2,"PAUSE") Also you probably want to add draw_set_halign(fa_center); draw_set_halign(fa_middle); so that its centered
You should use it every time you define a variable or use a function. It's not needed after a code block like an if statement or loop, just like most programming languages. The game might work without the semicolons, but it might create errors, and you should add them anyway to avoid confusion.
+Taylor Tindol I've found 2 ways to do it. 1. Since the default depth for your created text is 0, you can set all your other object's text to a number bigger than 0, that way all other objects will be underneath the text. 2. Use the "with" statement to define the depth when you draw the text. So everything would look the same the way he had it, but on the draw text you would put with(draw_text(x, y, "Paused Game")) { depth = -100 } "with" lets you define an object's characteristics when you create it.
In my game I have the money displayed at the top left corner of the screen. Now when I pause the game, that text displaying the money moves left and goes off-screen a little. Help Please?
I don't know if it still matters or not, but you can set image speed to 0 when paused. Doing that stops the animation completely, and setting it to 1 resumes the animations.
8 лет назад
Would this work if we make an object called obj_pausable which only has a step event with the line if (global.paused) exit; and have every object that we want to be pausable be children of this object??
My problem is that the majority of my enemies code is not in a step event and my if (global.pause) exit isn't working on the codes outside of the step event please help!
Jared Bauer Try a d&d test variable in teh control section. I dont this with some of my work, just make the variable global.pause and the value true/false
Is there a decent way to detect whether an instance is currently calling an alarm to execute or not? For an object I could create a variable that gets set to true when the alarm is called and sets to false when the alarm executes, and add ticks to the alarm if that variable is true; but I don't think that method would be very efficient.
Does anyone know how to enable tool tips. I can't get any to come up and is making it difficult to learn gm. I looked in preferences but still not working
hi Shaun I am having a problem with your enemies tutorial here is what the error says FATAL ERROR in action number 1 of Step Event0 for object obj_enemy: Push :: Execution Error - Variable Get -1.grav(100000, -1) at gml_Object_obj_enemy_StepNormalEvent_1 (line 2) - vsp += grav; please if you or anyone else can help me that would be great thanks
ok i have a problem, everything works as it should be, but the text does not show on top of the walls, which means you cant so the text when there are wall objects in the way.
For the alarm situation couldn't you just create your own alarm that ticks down every step event? This pauses the step event so that seems like it would make sense.
So I am trying to use this pause strategy with a view. However, the rectangle always draws in the upper left corner of the room no matter where the view is. The code I am using in the draw event of the pause object is: draw_rectangle(view_xview[0],view_yview[0],view_wview[0],view_hview[0],0); Any suggestions?
well it will keep drawing it in the top right because you set it there, you need to offset the location like view_xview[0] / 2 - 200 or view_yview[0] / 2 -200 or else it will keep drawing it at the top left try this, it may help: (view_xview[0]/2 -num,view_yview[0]/2 -num,view_xview[0]-num,view_yview[0]-num)
I'm a little stuck. I want my game to have the "System" typeface used as the font, but I can neither use that as a font nor add it into the game, it seems. Neither does it work with Terminal, which is similar. Any tips?
Hey Shaun, I was wondering something because I have come across a very strange problem. For some reason, when I press the escape key, nothing happens at all. I checked the code and everything and nothing happens. I was wondering why it was doing this.
My code is as follows for the draw. It now works, but the Game Paused string appears in the top left corner and moves out of the screen. And the obj stops after my player is out of the same space as the object is in because it is a space shooter that keeps on moving.
I have 2 questions towards this method: 1. Is it possible to program the pause menu to dim the objects as well as a the background? 2. When using views for your game (rather than using the full room) Is it possible to make the text that appears when paused to be centered onto that view?
My view follows my character. I've looked trough the comments and used some of the code suggested but it doesn't do anything for me. The text is not centered on my view.
Nikolaos Giannoulatos This (80%) works: draw_text(view_xview + view_wview/2, view_yview + view_view_hview/2, "Your text here") Yeah so just insert [] and mess around with the view_set_halign(fa_left/fa_center/fa_middle) probably fa_middle Hope this helped!
I'm trying to make the background see through when you hit pause like in the vid but it keeps giving me a solid black background :/ I used: draw_set_color(c_black); draw_set_alpha(0.5); draw_rectangle(0,0,room_width,room_height,0); draw_set_halign(fa_center); draw_set_font(font1); draw_set_color(c_white); draw_set_alpha(1); draw_set_color(c_black); Help?
The 2nd method is working a bit better for me than this one. What if an object that's moving, doesn't have a step event? I'm actually following your first game tutorial, and the obj_asteroid and a few others don't have step events. Even when they do, like obj_player, I plugged in the code and it's still moving at my command, nothing's paused. :/ The only thing I don't like about method 2 is that it doesn't render anything. I want the player to be able to see the screen just before hitting the escape button to UNPAUSE the game, in case they were about to run into something. Want it to be a fair game, you know. Any help on that?
I'm using a system for movement of my enemies like this: move_towards_point(obj_player.x,obj_player.y,6); however, when I pause the game they keep moving, every other step event pauses exactly like it should but it seems that this line of code keeps running, any help?
is there anything that has to change now? It isn't working for me and I've tried looking in the comments but haven't seen anything that works but haven't found anything. Can anyone help out?
So I'm using this for a TDS engine and the if (global.pause) exit; is working for the player except one problem, I have no idea how to make the bullet stop moving
Evan LeClair Hi, I could help you with that. Im making a tds game too and just added the pause menu. This is what I done - if (global.pause){ speed = 0 }else{ speed = 48 } adjust the speed obviously to what you have. Hope this helps.
If you have a problem with it not showing up, more than likely it's behind your room, instead of setting the depth of your pause object to zero, set it less than zero like -1, or -999, in case you have multiple layers on your room.
soooooooo, anyone else having problems. GM does not like "global.pause" anymore. if i just use "pause", it says a value cannot be assigned to a constant
Poliswag Jr. ThIs is better, but Essentially the same: draw_text(view_xview + view_wview/2, view_yview + view_view_hview/2, "Your text here") Yeah so just insert [] and mess around with the view_set_halign(fa_left/fa_center/fa_middle) probably fa_middle Hope this helped!
Hard to say, did you put the code in the button_check event or the keyboard_check_pressed event? Also did you make sure not to write something like global.pause = !global.pause? Oh and do you set the variable to false anywhere that might be likely to cause it to flash lol
Ugh. I hate my life. I worked all day on my game. Then I search up how to change the project name, and it said to rename the project file and the directory. So I did that, and now I can't open the project. I have to redo EVERYTHING.
EverythingZelda It's late, but I had the same problem. Open any file and then open another project from File. Find the directory where your files are and then open the folder. Your game should be in there.
What do you exactly mean by color codes? If you refer to hexadecimal codes, its pretty simple: You can create colors from their hexadecimal value using the "$" symbol. col = $983c95 Where 98 is the blue component, 3c is the green component and 95 is the red component - The color would be purple. If you press F1 in GMS and search for the keywords "Colour And Blending" you can also read the whole chapter about that in the Help Section :)
Hey Shaun! I added some background music to my platformer and I can't figure out how to make the music pause aswell. I tried editing the code, I even tried making a new object for everything but I cant seem to figure it out. Thanks in advance :)
audio_pause_sound audio_resume_sound You need to work with bolean variables to make this work.(at least most of the time) And yes sounds is a pain in the ass.
I've successfully created a menu which can close the program and start the game. also if you were to press ESC in the game, it would open the menu again. If i click start game it just respawns. Ive used the goto room next and goto room previous lines
I might make my own "alarms" that are based around personal variables. just using a way I actually understand how to do it. I will probably make my "alarms" be a variable that ticks down to 0 each step, which would then make it so it does pause with this kind of system.
Great video as always:) I think it's worth noting though that GMS now requires brackets around strings for some odd reason so it should look something like this now: draw_text(x,y,string("Game Paused")); This was a source of some frustration for me before I figured it out so I thought I'd spare whoever reads this the headache in case they don't yet know that.
Sorry mate but indeed, that's a lazy question. But to answer it: It's called Game Maker Language (or GML for short). A simple name but exactly what it is. It's an extremely easy language to learn and use, as the syntax is very forgiving, and if you've ever programmed in any language; BASIC, C, PHP, Java or anything else, you can pretty much program GML.
Brilliant tutorial! Although, I am running into a few problems. In my rooms I have two objects where I have drawn text (to display the score and the lives) and they have been created to sit in specific locations. When I press escape, these objects jump slightly to the left and it doesn't go back when I exit the pause menu...I don't know if any of that made sense, but if anyone could help me out that'd be great!! :D
Lets say I added this to my Asteroid game from your series. It says "Game paused" but everything is still in motion. My ship moves(cannot be controlled while the game is paused, though ) and asteroids still move as well. However, my ship does not get destroyed when an asteroid touches. So it's somewhat satisfactory.
if (global.pause == 0); { global.pause = 1; } else { ERROR at line 5 pos 3: Unexpected symbol is expression What the fuck. It turns yellow so it recognises it .but It says that and wont let me start my game :L Help :S
***** Hey, great video. I'd actually just been trying (and struggling lol) to add a pause system to my game. I'm now trying to create help text signs that, when the player is overlapping them, will show instructional text (i.e. how to move, this is an enemy, etc.) until the player stops overlapping the sign. However, using the method of displaying text you used in this tutorial, I can't seem to get the text to appear. Mind looking over this? In the sign's step event: if (place_meeting(x,y,obj_player)) { draw_set_halign(fa_center); draw_set_font(fnt_menu); draw_set_color(c_white); draw_set_alpha(1); draw_text(room_width/2,room_height/2,"Press the left and right arrow keys to move the player."); } Thanks in advance to anyone that helps :)
you can put: if(global.pause = 1){ alarm[alarm number] += 1; } inside your step event above the if statement this will instantly make your alarm go back up by one each time it goes down. easy fix for alarms that keep going.
Windows 8 doesn't support some functions (like game_end) because of the way Windows 8 applications work. If you show me the error and line of code the error occurs, i can help you out finding alternatives.
It's a visual overlay sure, but you can have it set in the step event so that a variable changes when the player presses the up or down arrow key, resetting after rising above its set maximum. Pressing space in this mode would either bring you to a sub-menu or select the option (controlled by the previous variable I mentioned). You would then control the position of the arrow (on the screen) by drawing it at different set areas depending on the submenu and the variable. All of this would be controlled by a few simple lines of code in the step and draw events. Pretty simple, all you have to do is build off of this tutorial.
You should write the if (global.pause == 0)... thing into press Event, not in the Create event. in the create event you should write *global.pause = 0;* I hope, that i have helped you out :)
answering the question before it shows up, if your room is bigger than your view you want to use view_xview and view_yview instead of room_width and room_height.
Great tut
Brilliant, thank you so much
lol
[resolved]
When I replace those two, it didn't work. Could you elaborate? (the following writes the text in the top left (no black rectangle))
-----------------------------------------------------------------
if (global.pause)
{
draw_set_color(c_black);
draw_set_alpha(0.5);
draw_rectangle(0,0,view_xview ,view_yview ,0);
draw_set_halign(fa_center);
draw_set_font(fnt_prn3);
draw_set_color(c_yellow);
draw_set_alpha(1);
draw_text(view_xview /2,view_yview /2,"Connection Paused");
draw_set_color(c_black);
}
there is nothing wrong with that right there. you have the view turned on right? Also you are using view 0? your code worked fine for me
eviltowely
Gotta go facepalm, brb. Another object was controlling the view[0] using code.
Thanks for the response, and enjoy your day!
I understand that this video is very old, but I still found it useful and I'm sure others do as well. A quick tip for the issue regarding alarms, instead of using GM:S' built in alarms you can make your own by running setting a global variable (I use global.timer_x where x is a number to separate unique timers) to the value you would set your alarm and just have the global variable decrease by 1 in the step event of the object its related to and have your code run once it hits 0, that way when you exit out of the objects step event it also pauses you alarms/timers. (You can also use local variables if the alarm only affects the one object it's attached to, but I would recommend setting global variables in you game initialization just to make things easier to work with and having all your eggs in one basket kind of thing)
Thanks for this, it is a very simple but useful insight. I'm looking forward for better implementations (maybe more complete/straightforward) and a possible actual menu on pausing. Love your videos, keep up the good work as always.
Out of all the methods I've tried, this one just seems to work the best, which is convenient because of how straight forward it is. Alarms can be a problem, but making "custom" or kind of "homemade" alarms in step events is an easy solution, and is still simpler than other methods I've used.
how would I make it follow my obj_camera?
+MattVideo Productions i wanna know too!
+MattVideo Productions FOUND IT! draw_text(view_xview[view_current] + view_wview[view_current] / 2, view_yview[view_current] + view_hview[view_current] / 2, "PAUSED");
+Jimm Well you found it from someone else just saying but thanks for commenting anyway i saw yours first
although i didnt find it anywhere, i just tinkered with it and after like 30min i got a hold of it ^^
ok then... if ya say so
*cough**cough* Steve Vautour 8 months ago
@ Destro700
Is your room bigger than your view? Use something like this:
draw_text(view_xview[view_current] + view_wview[view_current] / 2, view_yview[view_current] + view_hview[view_current] / 2, "PAUSED");;des i found it !
ahem
That's really a nice idea to create a pause system in a game. On the other hand, working this way involves dealing with controls checking, objects movement, collision checking and on all in the step event; btw I think I'll redefine my games with this new knowledge...
Nice pause work :)
If you want to manage your loads, exit the game in the pause menu, I recommend creating objects like obj_exit or obj_load on obj_pause's step event in if (global.pause == 1) {instance.create(yourstuffs)} and then add a left click event to use a load script (as shown on Shaun in early tutorials) or exit the game.
This way to pause a menu is a bit tricking the computer because in fact in just freeze ennemies and player but it works well on little games so thank you Shaun.
Quick tip: for toggling 1/0 or true/false use "var = 1 - var"
Or simply "var = not var;"
Or even more simple "var =! var"
Alarm system is just an array.
When starting pause copy all `alarm` values to `my_paused_alarms` and set every alarm to -1, when resuming copy back from `my_paused_alarms` to `alarm`. Or don't bother with alarm system at all, decrement counters in step event, you will get better naming. 3 days later variable `next_boss_phase_counter` makes much more sense than `alarm[5]`.
5.24 after doing this, my screen darkened but no text showed up (even after quickly adding a font set as Arial) why is my text not showing up? Also 8:00 I added [if (global.pause) exit;] (without brackets) to my obj_Enemy's step event and it didn't stop it at all. The background dimming action works though!
Thank you for making this video! I've been looking for something like this for a long time.
how you do this for the view window? I try this out and it prints the inputs in the middle of the room but the view is still focus where the player is
Hey I have the same problem, did you end up finding a solution?
The tutorial ddi not worked to me. Is there some functions or variable to be pre-determinated before thsi video?
It's possible with that system to have not errors with timers.
In every frame if pause you easily can add one frame to all your timers.
example:
if (global.pause)
{
alarm[0] ++ or +=1
exit;
}
and that for every Timer :D
***** Ok sorry,
Yes I can imagine.
By the way you are making cool Videos.😊
***** Yes and no I think, I just created this same pause system for my game weeks ago and did the += 1 thing on all timers and I ran into that issue of pausing at the worst frame. But you should be able to circumvent that issue easily by saying "if alarm[] < 0 alarm[] +=1" this way it only pauses the alarms if its active.
***** So smart ! :D
***** Okay come on, we're programmers here:
if global.pause && alarm[0] > 0{alarm[0] += 1;}
If an alarm has already hit -1, then it's essentially executing the code, assuming someone paused on that point (for this example let's say something would be created when the alarm went off), the object would be created and should then in turn notice that the pause variable was set to true. This would then pause that object. Let's be realistic, it's almost impossible for a player who isn't looking very very hard to spot that one step difference.
And now that I read ahead it seems someone already beat me to it. Matthew Lemmel
***** I use a very similar pause system approach in my game. To solve the alarm issue, at the moment the game gets paused, I looped through every pausable object, stored all of their alarm values into an array, as well as the instance's id. Then set their alarm's value to 0 to deactivate the alarm. Then when I unpause the game, I simply looped through the array and restored the alarm's value. It has worked very well. I do the exact same thing for every object's gravity, hspeed, vspeed, image_speed and path_speed
What button did you press at 2:08 to space from here to here in the code?
Tab
this tutorial was perfect great job m8
Nice video. I look forward to seeing the next tutorial in the series.
I've got a few comments.
1. You might have just been doing it your way to keep the code easier to understand but at 2:00 you could have done global.pause= 1-global.pause, or if you were using booleans (and in this case you are because of the way game maker variables work) global.pause=! global.pause is also valid
2. I've used this technique before and I've come across an issue with parenting. So let's say the parent has if(global.pause) exit; in the step event and I have a step event in the child using event_inherited() to manually inherit the step from the parent. When event_inherited() is called the event of the parent is exited but the rest of the code in the child step event still runs.
I guess the solution is to copy the code over to everything, but it's frustrating that parenting can't be used.
Whenever I use the pause feature the draw takes place below all of my other objects, so none of the characters are tinted grey and the pause text is often obsured by the level environment. :(
Please help :P
if i press pause, the overlay appears. But my object (with gravity) falls, how do i make it stop.
Is there a code to put in extra?
Thankyou so much for this video btw!!!
Use a global variable to hold the gravity value, set your gravity for your "object" to zero (0) in your if-else for your pause, when the player presses escape again, set the gravity of your "object" to the global variable. I'd recommend making your own global variable for your gravity vs using the Game Maker predefined Gravity. Could cause problems.
Welp. Use instance_deactivate_all(true); in your pause object when paused, and instance_activate_all(); when not paused.
I have the same issue as sascha and that doesn't even work. How do I fix it?
I have a problem, I don't have the movement or collision in the step event for my player, and I also don't have a step event for another object that changes sub-image every second (It does that automatically) and so the pause does not stop anything. Where would I put the code for stopping things? All of the movement and collisions are frag and drop.
What if i have set some view,how i can set the pause text,score,hp etc. to be in the view?
And how to menage it with alarms?
Oh I got it from another comment! Hopefully this works! draw_text(view_xview + view_wport / 2 ,view_yview + view_hport / 2,"PAUSE") Also you probably want to add draw_set_halign(fa_center);
draw_set_halign(fa_middle); so that its centered
Your "draw_set_halign(fa_middle)" should be valign "draw_set_valign(fa_middle)"
Question? Is it absolutely necessary to add a semicolon after every piece of code?
I never added it before and my game is working just fine.
not in gml, but in some other languages it is necessary. I would recommend making it a habbit.
I know for sure it is in Java, not sure about others. As the person before me said, make it a habit.
You should use it every time you define a variable or use a function. It's not needed after a code block like an if statement or loop, just like most programming languages. The game might work without the semicolons, but it might create errors, and you should add them anyway to avoid confusion.
Anyone know how to fix the problem where if you pause, objects overlay the pause text?!?!?!
+Taylor Tindol I've found 2 ways to do it.
1. Since the default depth for your created text is 0, you can set all your other object's text to a number bigger than 0, that way all other objects will be underneath the text.
2. Use the "with" statement to define the depth when you draw the text. So everything would look the same the way he had it, but on the draw text you would put
with(draw_text(x, y, "Paused Game"))
{
depth = -100
}
"with" lets you define an object's characteristics when you create it.
+Jordan Pool thanks bro ! :)
It's easier to set the pause menu to a negative depth. -999 should do the trick ;)
AJman14 hahaha that eas 36 weeks ago man i already finished my game
Well, anyone else reading the comments will see it, anyway
In my game I have the money displayed at the top left corner of the screen. Now when I pause the game, that text displaying the money moves left and goes off-screen a little. Help Please?
So moving objects return to the same velocity and direction as when unpaused?
My Character does not use step events it uses key presses and key releases. How do I get the animation to stop
I don't know if it still matters or not, but you can set image speed to 0 when paused.
Doing that stops the animation completely, and setting it to 1 resumes the animations.
Would this work if we make an object called obj_pausable which only has a step event with the line if (global.paused) exit; and have every object that we want to be pausable be children of this object??
No, children won't pause. You have to put the statement in the child's code, as well.
I thought that that children inherited every single behavior from their parents
My problem is that the majority of my enemies code is not in a step event and my if (global.pause) exit isn't working on the codes outside of the step event please help!
Jared Bauer Try a d&d test variable in teh control section. I dont this with some of my work, just make the variable global.pause and the value true/false
Is there a decent way to detect whether an instance is currently calling an alarm to execute or not? For an object I could create a variable that gets set to true when the alarm is called and sets to false when the alarm executes, and add ticks to the alarm if that variable is true; but I don't think that method would be very efficient.
Does anyone know how to enable tool tips. I can't get any to come up and is making it difficult to learn gm. I looked in preferences but still not working
how can you do the rectangle relative to your view
i have tried
draw_rectangle(view_current)
but for some reason it says error
help plzz
This method messes up my sprites depth and it creates instances that I did not put in the scene! Gms2 here. Any help?
hi Shaun I am having a problem with your enemies tutorial here is what the error says FATAL ERROR in
action number 1
of Step Event0
for object obj_enemy:
Push :: Execution Error - Variable Get -1.grav(100000, -1)
at gml_Object_obj_enemy_StepNormalEvent_1 (line 2) - vsp += grav;
please if you or anyone else can help me that would be great thanks
fixed it
is there any way to pause only one action instead of an whole event?
ok i have a problem, everything works as it should be, but the text does not show on top of the walls, which means you cant so the text when there are wall objects in the way.
is there a way to set up a script that just freezes everything when you are paused?
For some reason my Draw event does not work.. I have not idea how it is suppose to work, but the script inside do not run.
Why not make global.pause a bool? like just use global.pause = !global.pause to switch between on and off.
My enemies still move when i put in if (global.pause) exit; any fixes?
+LWT did you do it at the beginning of the step event of all the enemies?
Jimm Yes
then idk. i'd say you should either redo it all, or try the other method :)
Jimm k thanks for trying to figure it out
no worries
For the alarm situation couldn't you just create your own alarm that ticks down every step event? This pauses the step event so that seems like it would make sense.
So I am trying to use this pause strategy with a view. However, the rectangle always draws in the upper left corner of the room no matter where the view is. The code I am using in the draw event of the pause object is: draw_rectangle(view_xview[0],view_yview[0],view_wview[0],view_hview[0],0); Any suggestions?
well it will keep drawing it in the top right because you set it there, you need to offset the location like view_xview[0] / 2 - 200 or view_yview[0] / 2 -200 or else it will keep drawing it at the top left
try this, it may help:
(view_xview[0]/2 -num,view_yview[0]/2 -num,view_xview[0]-num,view_yview[0]-num)
Matthew Subrattie didn't work for me... should I change the "-num" to a number?
MrStopTeme well yes of course
Matthew Subrattie well, in that case, what number should I use?
MrStopTeme well try a number until you get a result that suits eg. 200,200,250,250
I'm a little stuck. I want my game to have the "System" typeface used as the font, but I can neither use that as a font nor add it into the game, it seems. Neither does it work with Terminal, which is similar. Any tips?
Can you explain how to make a pause menu using views please?
Hey Shaun, I was wondering something because I have come across a very strange problem. For some reason, when I press the escape key, nothing happens at all. I checked the code and everything and nothing happens. I was wondering why it was doing this.
My code is as follows for the draw. It now works, but the Game Paused string appears in the top left corner and moves out of the screen. And the obj stops after my player is out of the same space as the object is in because it is a space shooter that keeps on moving.
how you did font menu? plz help dude
I have 2 questions towards this method:
1. Is it possible to program the pause menu to dim the objects as well as a the background?
2. When using views for your game (rather than using the full room) Is it possible to make the text that appears when paused to be centered onto that view?
My view follows my character. I've looked trough the comments and used some of the code suggested but it doesn't do anything for me. The text is not centered on my view.
Nikolaos Giannoulatos
This (80%) works:
draw_text(view_xview + view_wview/2, view_yview + view_view_hview/2, "Your text here")
Yeah so just insert [] and mess around with the view_set_halign(fa_left/fa_center/fa_middle)
probably fa_middle
Hope this helped!
I'm trying to make the background see through when you hit pause like in the vid but it keeps giving me a solid black background :/
I used:
draw_set_color(c_black);
draw_set_alpha(0.5);
draw_rectangle(0,0,room_width,room_height,0);
draw_set_halign(fa_center);
draw_set_font(font1);
draw_set_color(c_white);
draw_set_alpha(1);
draw_set_color(c_black);
Help?
ooootttiiu
nvm..
+Pedro Mendes i found it ! draw_text(view_xview[view_current] + view_wview[view_current] / 2, view_yview[view_current] + view_hview[view_current] / 2, "PAUSED");
The 2nd method is working a bit better for me than this one.
What if an object that's moving, doesn't have a step event?
I'm actually following your first game tutorial, and the obj_asteroid and a few others don't have step events. Even when they do, like obj_player, I plugged in the code and it's still moving at my command, nothing's paused. :/
The only thing I don't like about method 2 is that it doesn't render anything. I want the player to be able to see the screen just before hitting the escape button to UNPAUSE the game, in case they were about to run into something. Want it to be a fair game, you know. Any help on that?
I'm using a system for movement of my enemies like this: move_towards_point(obj_player.x,obj_player.y,6); however, when I pause the game they keep moving, every other step event pauses exactly like it should but it seems that this line of code keeps running, any help?
I have a thing of text in my room and when i go in the escape menu it moves the text out of the room... Any fix?
Set that text to have a font. If it's not set, it'll grab the first font used, in this case, your Pause screen font.
is there anything that has to change now? It isn't working for me and I've tried looking in the comments but haven't seen anything that works but haven't found anything. Can anyone help out?
Is it possible to stop the motion of my ship and my asteroids if I follow your asteroids tutorial and continue their original motion when I resume?
So I'm using this for a TDS engine and the if (global.pause) exit; is working for the player except one problem, I have no idea how to make the bullet stop moving
Evan LeClair Hi, I could help you with that. Im making a tds game too and just added the pause menu. This is what I done -
if (global.pause){
speed = 0
}else{
speed = 48
}
adjust the speed obviously to what you have.
Hope this helps.
I'll try it, thanks!
If you have a problem with it not showing up, more than likely it's behind your room, instead of setting the depth of your pause object to zero, set it less than zero like -1, or -999, in case you have multiple layers on your room.
soooooooo, anyone else having problems. GM does not like "global.pause" anymore. if i just use "pause", it says a value cannot be assigned to a constant
I nenes help, i uses the code but my game uses views to move around and the pause does not appear in the middle of the view
*need
Poliswag Jr.
ThIs is better, but Essentially the same:
draw_text(view_xview + view_wview/2, view_yview + view_view_hview/2, "Your text here")
Yeah so just insert [] and mess around with the view_set_halign(fa_left/fa_center/fa_middle)
probably fa_middle
Hope this helped!
Guys when I Press the Esc, game is shutting down how can I prevent that.I want to use Esc key for an action.
can you create a video on using multiple save & load slots
When i hold down esc the pausing just flashes. pls help ?
Hard to say, did you put the code in the button_check event or the keyboard_check_pressed event? Also did you make sure not to write something like global.pause = !global.pause? Oh and do you set the variable to false anywhere that might be likely to cause it to flash lol
Zei33 Thanks
Make the even a release instead, the key press event is way too sensitive.
what happens to the vid? i see black flickring screen
Ugh. I hate my life. I worked all day on my game. Then I search up how to change the project name, and it said to rename the project file and the directory. So I did that, and now I can't open the project. I have to redo EVERYTHING.
GameCentral Then if that happens then your gamemaker project was damaged
You can try to create a new project and import every sprite, object, room ecc. of your game. I had the same problem and I resolved it.
EverythingZelda That sucks.
EverythingZelda It's late, but I had the same problem. Open any file and then open another project from File. Find the directory where your files are and then open the folder. Your game should be in there.
+Pile of Sand just clik export again :)
heh nice Just this morning I Fixed my Pause method utilizing your checkpoint tutorial this is pretty cool.
***** how can i fix the "out of memory" i literally tried all over on google and reinstalled my studio and still get the message please help me :(
I fixed it by uninstalling gms, deleting the gamemaker folder in the appdata folder and in the registry, then reinstalling.
ok ill try it asap thanks
eviltowely where is Registry again i cant seem to find it
Sebastian Zeballos Alt+R (Or Win+R on Windows 8/8.1), then type regedit and click 'OK'
Ok thanks
can you use color codes for the text color?
What do you exactly mean by color codes? If you refer to hexadecimal codes, its pretty simple:
You can create colors from their hexadecimal value using the "$" symbol.
col = $983c95
Where 98 is the blue component, 3c is the green component and 95 is the red component - The color would be purple.
If you press F1 in GMS and search for the keywords "Colour And Blending" you can also read the whole chapter about that in the Help Section :)
exactly what I was looking for, thanks!
When I do it, my text wont go over the platforms and same with the rectangle.
+MrmeowerGaming Set the depth of obj_pause to -99999. Just make that number higher than anything else so it draws it in front of everything.
Thanks!
Hey Shaun! I added some background music to my platformer and I can't figure out how to make the music pause aswell. I tried editing the code, I even tried making a new object for everything but I cant seem to figure it out. Thanks in advance :)
I'm going to tell you right now, music is a bloody pain in Game Maker, also watch out for all the legacy functions.
audio_pause_sound
audio_resume_sound
You need to work with bolean variables to make this work.(at least most of the time) And yes sounds is a pain in the ass.
I've successfully created a menu which can close the program and start the game. also if you were to press ESC in the game, it would open the menu again. If i click start game it just respawns. Ive used the goto room next and goto room previous lines
Does this method pause alarm ticks too?
and it autosaves at checkpoints and level switches please
can we get the project download???????
This works great, but the 0.5 alpha is being applies to everything in my level, not just the drawn rectangle.
how can i set that the pause followes the view plss help :D
I might make my own "alarms" that are based around personal variables. just using a way I actually understand how to do it.
I will probably make my "alarms" be a variable that ticks down to 0 each step, which would then make it so it does pause with this kind of system.
Ty so much it's still work in gamemaker studio 2
When I pause, an alarm of my player continue. How do I stop it?
Great video as always:) I think it's worth noting though that GMS now requires brackets around strings for some odd reason so it should look something like this now: draw_text(x,y,string("Game Paused")); This was a source of some frustration for me before I figured it out so I thought I'd spare whoever reads this the headache in case they don't yet know that.
I may sound dumb by asking this, but what language does game maker use?
Less 'dumb', more 'lazy'. The answer is seriously 1 google search away.
Sorry mate but indeed, that's a lazy question. But to answer it: It's called Game Maker Language (or GML for short). A simple name but exactly what it is. It's an extremely easy language to learn and use, as the syntax is very forgiving, and if you've ever programmed in any language; BASIC, C, PHP, Java or anything else, you can pretty much program GML.
Brilliant tutorial! Although, I am running into a few problems. In my rooms I have two objects where I have drawn text (to display the score and the lives) and they have been created to sit in specific locations. When I press escape, these objects jump slightly to the left and it doesn't go back when I exit the pause menu...I don't know if any of that made sense, but if anyone could help me out that'd be great!! :D
can you make a video on how to make the pause as big as your veiw????
doesn't work, I wrote everything down corrected it, nothing was wronge, and when I pressed it it crashed
Lets say I added this to my Asteroid game from your series.
It says "Game paused" but everything is still in motion. My ship moves(cannot be controlled while the game is paused, though ) and asteroids still move as well. However, my ship does not get destroyed when an asteroid touches. So it's somewhat satisfactory.
Still works, thanks
if (global.pause == 0);
{
global.pause = 1;
}
else
{
ERROR at line 5 pos 3: Unexpected symbol is expression
What the fuck.
It turns yellow so it recognises it .but It says that and wont let me start my game :L
Help :S
if (global.pause == 0)
{
global.pause = 1;
}
else
{
Project download: [Coming soon]
We are on 2018...
It's in part 2
2020
2021
what if my view is smaller than my total room?
***** Hey, great video. I'd actually just been trying (and struggling lol) to add a pause system to my game. I'm now trying to create help text signs that, when the player is overlapping them, will show instructional text (i.e. how to move, this is an enemy, etc.) until the player stops overlapping the sign. However, using the method of displaying text you used in this tutorial, I can't seem to get the text to appear. Mind looking over this?
In the sign's step event:
if (place_meeting(x,y,obj_player))
{
draw_set_halign(fa_center);
draw_set_font(fnt_menu);
draw_set_color(c_white);
draw_set_alpha(1);
draw_text(room_width/2,room_height/2,"Press the left and right arrow keys to move the player.");
}
Thanks in advance to anyone that helps :)
Whoops, aha no more late-night coding for me. I just realized I put it in the step event, not the draw event.
you can put:
if(global.pause = 1){
alarm[alarm number] += 1;
}
inside your step event above the if statement this will instantly make your alarm go back up by one each time it goes down. easy fix for alarms that keep going.
It freezes the game when I unpause I need help
Shaun you should do a tutorial on a Highscore menu. There are a lot of tutorials but none explain things as well as you do in your videos.
i did everything the video says me to do, but it doesn't enything.
Does not work in 8.1
wut..
NoDillonTheHacker
Doing exactly what he shows here causes your game to crash in Game Maker 8.1 when you try to run it.
Windows 8 doesn't support some functions (like game_end) because of the way Windows 8 applications work. If you show me the error and line of code the error occurs, i can help you out finding alternatives.
B r a n d o n That's because this is a tutorial for GameMaker Studio, not GameMaker 8.1
Alpha Hedge Using GM 8.1 can assure you it works
Now how to with gamepad?
***** i dont understand the end of your game Another Perspective, explain for me please?
do enemy collision, with knockback :)
It's not really a "menu". Just an overlay. A menu would have things you can select.
It's a visual overlay sure, but you can have it set in the step event so that a variable changes when the player presses the up or down arrow key, resetting after rising above its set maximum. Pressing space in this mode would either bring you to a sub-menu or select the option (controlled by the previous variable I mentioned). You would then control the position of the arrow (on the screen) by drawing it at different set areas depending on the submenu and the variable. All of this would be controlled by a few simple lines of code in the step and draw events. Pretty simple, all you have to do is build off of this tutorial.
You should add a parent obj to everything so it’s easy to pause everything
Hey can u help make a game with me maybe?
Push :: Execution Error - Variable Get -5.pause(100015, -2147483648)
at gml_Object_obj_enemy_StepNormalEvent_1 (line 1) - if (global.pause) exit;
You should write the if (global.pause == 0)... thing into press Event, not in the Create event. in the create event you should write *global.pause = 0;* I hope, that i have helped you out :)
I wish I learned about the exit function 4 years ago when I started game maker.
Agreed. I feel you man.