Jump to content


Photo

Pause menu


  • Please log in to reply
28 replies to this topic

#1 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 11 March 2012 - 12:08 AM

Okay i want to make something where you have a pause menu by pressing "P". But the only problem I've never had any expirience with this kinda stuff. So... i dont know where to start :sad:.

Please help me asap! :thumbsup:
  • 0

#2 RangerX

RangerX

    GMC Member

  • GMC Member
  • 916 posts
  • Version:GM8.1

Posted 11 March 2012 - 12:13 AM

Drag and Drop or GML? I just made myself a Pause menu today
  • 0

#3 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 11 March 2012 - 03:26 PM

wow ranger thanks for well... nothing -_-
  • 0

#4 RangerX

RangerX

    GMC Member

  • GMC Member
  • 916 posts
  • Version:GM8.1

Posted 11 March 2012 - 03:33 PM

I need to know if you want help in GML or in Drag and Drop icons. If it's icons, I can't help you so I have to know.
  • 0

#5 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 11 March 2012 - 03:39 PM

i

Edited by Quazarr, 11 March 2012 - 03:41 PM.

  • 0

#6 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 11 March 2012 - 03:40 PM

I want to use GML

Edited by Quazarr, 11 March 2012 - 03:40 PM.

  • 0

#7 RangerX

RangerX

    GMC Member

  • GMC Member
  • 916 posts
  • Version:GM8.1

Posted 11 March 2012 - 04:41 PM

Ok, here's how it did it (logic):

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.

  • 0

#8 TheUltimate

TheUltimate

    Life is Awesome

  • GMC Member
  • 991 posts
  • Version:GM8

Posted 11 March 2012 - 08:55 PM

Here's how I did it in my game. You can go check it out to see if that's the sort of thing you'd like, but it's essentially the same as RangerX's description.

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.

  • 0

#9 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 11 March 2012 - 09:14 PM

how do i make buttons that say "Resume", "Save", and "Exit"? And also with the pause menu can u make it so the WHOLE screen is transparent black with all the color when i press "P"?

Edited by Quazarr, 11 March 2012 - 09:19 PM.

  • 0

#10 TheUltimate

TheUltimate

    Life is Awesome

  • GMC Member
  • 991 posts
  • Version:GM8

Posted 11 March 2012 - 09:26 PM

To make the whole screen black, you have to adjust the numbers in the draw event. Probably something like this:
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.

  • 0

#11 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 11 March 2012 - 09:50 PM

lol ok thanks for the help! :D
  • 0

#12 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 11 March 2012 - 10:05 PM

OMG i cant find any tutorials for it D:
  • 0

#13 Jakyl11

Jakyl11

    GMC Member

  • GMC Member
  • 3109 posts
  • Version:GM:Studio

Posted 11 March 2012 - 10:11 PM

double posting = a bad thing to do ...

anyway do you have pro version of gm8 or gm8.1?
  • 0

#14 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 11 March 2012 - 10:14 PM

yes i do but for my contest im not aloud to use it :(
  • 0

#15 RangerX

RangerX

    GMC Member

  • GMC Member
  • 916 posts
  • Version:GM8.1

Posted 11 March 2012 - 10:26 PM

If you want to whole screen black when you pause, set up a blackground in your room options but don't make it visible. When you press P-Key, make that background visible:

Here's my own P-key event as an example:

if(InPause=false)
then
{
background_visible[4]=true;
instance_deactivate_all(true);
InPause=true;
}

  • 0

#16 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 11 March 2012 - 10:28 PM

Only thing i need right now is how to get the buttons?

Edited by Quazarr, 11 March 2012 - 10:30 PM.

  • 0

#17 Jakyl11

Jakyl11

    GMC Member

  • GMC Member
  • 3109 posts
  • Version:GM:Studio

Posted 11 March 2012 - 10:32 PM

alright i fixed up a resource file with TheUltimate's example and slightly altered it.

http://www.mediafire...06y3s8q37emmlbb
  • 0

#18 RangerX

RangerX

    GMC Member

  • GMC Member
  • 916 posts
  • Version:GM8.1

Posted 11 March 2012 - 10:34 PM

How do you want your menu to work? There's many ways to do this.
Do you want buttons selectable by keyb or mouse? It could also be drawned text with a selector, etc.
  • 0

#19 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 11 March 2012 - 10:35 PM

selectable by mouse
  • 0

#20 RangerX

RangerX

    GMC Member

  • GMC Member
  • 916 posts
  • Version:GM8.1

Posted 11 March 2012 - 10:36 PM

Sorry for the questions but...
and you want only one simple save? (simpler than having different save slots)
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users