Please help me asap!
Pause menu
#1
Posted 11 March 2012 - 12:08 AM
Please help me asap!
#2
Posted 11 March 2012 - 12:13 AM
#3
Posted 11 March 2012 - 03:26 PM
#4
Posted 11 March 2012 - 03:33 PM
#5
Posted 11 March 2012 - 03:39 PM
Edited by Quazarr, 11 March 2012 - 03:41 PM.
#6
Posted 11 March 2012 - 03:40 PM
Edited by Quazarr, 11 March 2012 - 03:40 PM.
#7
Posted 11 March 2012 - 04:41 PM
I made a "pause object". I put a little boolean variable called "InPause=false" in its create event.
Then there's P-key press event.
Now, when the player press P, I deactivate all the instance except the Pause Object and then make a previously set black background visible (this background could obviously be anything). Lastly, that event sets my "InPause" variable to true.
In a draw event, I draw what I need on screen over that black blackground. Personally I wanted a simple message like "the game is paused" and "press backspace to resume". All of this under the condition that "InPause" must be true.
After that I made a "backspace key press" event in the Pause Object. That one makes the black background invisible and reactivate all instances. It also turns back "InPause" to false.
And voila, you have a simple and versatile Pause menu done.
With this logic and the exact syntaxe in the help section, you can easily get this done. Look up in help index for functions like:
deactivate_all_instances
activate_all_instances
draw_text_ext
also you need the "background_visible" variable.
have fun
Edited by RangerX, 11 March 2012 - 04:43 PM.
#8
Posted 11 March 2012 - 08:55 PM
You put this in a control object that's always in the level.
// Key pressed "P" event (the one with the red arrow)
paused=!paused
// Hitting P pauses and unpauses the game. When you hit P, the "paused" variable
// goes from 0 to 1 and vice-versa
if paused==1
{
instance_deactivate_all(true)
// Make sure it's "true" so that the object this code is in will stay active so
// you'll be able to unpause the game!
}
else
{
instance_activate_all();
paused=0
}
// Draw event
if paused==1
{
instance_deactivate_all(true)
// Kind of redundant, but I just left it in there anyway
draw_set_color(c_black)
draw_rectangle(view_xview,view_yview,view_xview+600,view_yview+400,false)
// The numbers are the view size. Change it to whatever yours is.
draw_set_color(c_white)
draw_set_halign(fa_center)
// Set colour and alignment of drawn text
draw_text(view_xview+300,view_yview+195,"PAUSED")
// Draw text in the middle of the screen
draw_set_halign(fa_left)
draw_set_color(c_black)
// The previous two lines just reset the drawing stuff so it won't mess up the rest of
// the text that displays in the game. You may or may not need this.
}
Hope that helps.
◊ TheUltimate ◊
Edit: Whoops, random typo.
Edited by TheUltimate, 11 March 2012 - 09:00 PM.
#9
Posted 11 March 2012 - 09:14 PM
Edited by Quazarr, 11 March 2012 - 09:19 PM.
#10
Posted 11 March 2012 - 09:26 PM
draw_rectangle(view_xview,view_yview,view_xview+640,view_yview+480,false)You have to check what your view size is and adjust it accordingly. You can also use draw_sprite if you want a picture instead of a black rectangle.
As for the Resume, Save, and Exit, just look up how to make a menu. There are a lot of good tutorials on how to do that, and they probably explain it better than I do.
◊ TheUltimate ◊
Edited by TheUltimate, 11 March 2012 - 09:27 PM.
#11
Posted 11 March 2012 - 09:50 PM
#12
Posted 11 March 2012 - 10:05 PM
#13
Posted 11 March 2012 - 10:11 PM
anyway do you have pro version of gm8 or gm8.1?
#14
Posted 11 March 2012 - 10:14 PM
#15
Posted 11 March 2012 - 10:26 PM
Here's my own P-key event as an example:
if(InPause=false)
then
{
background_visible[4]=true;
instance_deactivate_all(true);
InPause=true;
}
#16
Posted 11 March 2012 - 10:28 PM
Edited by Quazarr, 11 March 2012 - 10:30 PM.
#17
Posted 11 March 2012 - 10:32 PM
http://www.mediafire...06y3s8q37emmlbb
#18
Posted 11 March 2012 - 10:34 PM
Do you want buttons selectable by keyb or mouse? It could also be drawned text with a selector, etc.
#19
Posted 11 March 2012 - 10:35 PM
#20
Posted 11 March 2012 - 10:36 PM
and you want only one simple save? (simpler than having different save slots)
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











