Jump to content


Photo
* * * * * 2 votes

Pause your game tutorial


  • Please log in to reply
15 replies to this topic

#1 Pandaboy

Pandaboy

    GMC Member

  • GMC Member
  • 714 posts

Posted 19 March 2012 - 06:19 AM

  • Title: Pausing your game
  • Description: Pauses your game when pressing a key on your keyboard.
  • GM Version: :GM8:
  • Registered: yes & no (you can choose)
  • File Type: .gmk
  • File Size: 28.3 KB
  • File Link: yoyogames link
Summary
A very simple examlpe that shows you how to pause the game by pressing a key on the keyboard.
It uses only 6 lines of code to pause the game (and some additional lines to draw "game paused" on the screen).
You can easily implement it into your game by copying obj_pause to your game project.

If you want a pause menu to pop up when you pause the game, it's easy to add that using this as a base. A nice way to achieve this is to give all pause menu objects a parent (name it parent_menu), and in the create event of obj_pause, you write the following code: instance_activate_object(parent_menu);. You will also need to give it a code to stay on the screen if you are using views.

Note:
GM Pro is required for one of the functions, so the .zip file also includes a .gmk which works with GM lite. the only downside to this is that unless you have pro, all objects on the screen will turn invisible when you pause. but then again, that's exactly how pausing in old mario games worked (i guess nintendo didn't have GM pro back then ;D)


Feel free to comment and rate the tutorial/example on the yoyogames website, and feel free to post any question here ^^

Edited by Pandaboy, 29 March 2012 - 02:02 AM.

  • 5

#2 Pandaboy

Pandaboy

    GMC Member

  • GMC Member
  • 714 posts

Posted 28 April 2012 - 03:26 PM

hello world :3.
no comments yet :o?
  • 0

#3 creators124

creators124

    awesomeliciousmember

  • GMC Member
  • 866 posts
  • Version:GM8

Posted 28 April 2012 - 07:22 PM

is there a way to make a selection thing in pause so the player can select an option?
not very bright with the draw event! :(
I'm using the lite version! :P
  • 0

#4 _254583

_254583

    GMC Member

  • New Member
  • 32 posts

Posted 28 April 2012 - 07:27 PM

is there a way to make a selection thing in pause so the player can select an option?
not very bright with the draw event! :(
I'm using the lite version! :P


A trick I used is to create an object with the options you want inside (created however you want to do that) and simply use the code instance_activate_object(YOUROBJECTNAME); after the any code which deactivates all objects. This will stop everything, and then bring this object to life. This will only work if an instance of the pause object is in the room. If not, it's even simpler use instance_create(x,y,OBJECTNAME); and this will create the object, and it'll be active.
  • 0

#5 creators124

creators124

    awesomeliciousmember

  • GMC Member
  • 866 posts
  • Version:GM8

Posted 28 April 2012 - 07:31 PM

A trick I used is to create an object with the options you want inside (created however you want to do that) and simply use the code instance_activate_object(YOUROBJECTNAME); after the any code which deactivates all objects. This will stop everything, and then bring this object to life. This will only work if an instance of the pause object is in the room. If not, it's even simpler use instance_create(x,y,OBJECTNAME); and this will create the object, and it'll be active.

Great thanks! Posted Image
But now I have to figure out how to make the pause menu! :P
EDIT:
How do you make text make a flashing type of animation?
EDIT2:
YAY!
I figured it out!:P
EDIT3:
how do you make tiles not visible? :P
I seem not being able to do it!

Edited by creators124, 28 April 2012 - 10:36 PM.

  • 0

#6 creators124

creators124

    awesomeliciousmember

  • GMC Member
  • 866 posts
  • Version:GM8

Posted 01 May 2012 - 08:37 PM

I've changed it so that it has options!
would you like to see?

Edited by creators124, 05 May 2012 - 04:59 PM.

  • 0

#7 Nathaniel

Nathaniel

    GMC Member

  • GMC Member
  • 507 posts
  • Version:GM8

Posted 27 May 2012 - 11:03 AM

thank you so much!
  • 0

#8 Artist&Awesome

Artist&Awesome

    GMC Member

  • GMC Member
  • 20 posts
  • Version:Unknown

Posted 04 July 2012 - 06:34 PM

Thanks, So good, I'm using it in one of my tuts. :D
  • 0

#9 Hiznopellagio

Hiznopellagio

    Call Me Hiz.

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

Posted 21 July 2012 - 09:44 AM

Nice one! may i use some sprite there?
  • 0

#10 Pandaboy

Pandaboy

    GMC Member

  • GMC Member
  • 714 posts

Posted 26 July 2012 - 01:38 AM

Nice one! may i use some sprite there?


Sure, I made those sprites quickly for that tutorial, feel free to use them :)
  • 1

#11 Hiznopellagio

Hiznopellagio

    Call Me Hiz.

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

Posted 26 July 2012 - 10:28 AM

Thanks dude! +1!
  • 0

#12 TaiBoGames

TaiBoGames

    GMC Member

  • New Member
  • 40 posts
  • Version:Unknown

Posted 30 December 2012 - 12:29 AM

This rules! It solved my pause menu problem. Thanks!
  • 0

#13 bnecitizen

bnecitizen

    GMC Member

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

Posted 10 January 2013 - 12:51 AM

Is it supposed to zoom in to a particular section of the screen when paused?
  • 0

#14 Pandaboy

Pandaboy

    GMC Member

  • GMC Member
  • 714 posts

Posted 10 January 2013 - 01:51 AM

Is it supposed to zoom in to a particular section of the screen when paused?


Are you using GM: Studio?
I've experienced zooming bugs when copying parts of the screen to a sprite with GM Studio.

so, no, it shouldn't do that normally..
But if you are using studio, it's most likely a bug from Game Maker's side.

This may be a temporary way to bypass it until YoYo fixes the bug:
Spoiler

Edited by Pandaboy, 10 January 2013 - 02:00 AM.

  • 0

#15 Chivanton

Chivanton

    GMC Member

  • GMC Member
  • 1 posts
  • Version:GM8

Posted 10 January 2013 - 02:46 AM

It's great for pausing! I wish I could really use it, as it keeps flashing my "obj_pause_menu" when I press the pause key "P" :confused:. I can't post a picture of it as it happens really quickly. I've copied every event in it, as I want the same things to happen, except for the Draw Event.

If you could help me I would really appreciate it, as finding the pause action I wanted wasn't so easy, until I saw your post, good sir :thumbsup:

EDIT: I have copied some of the scripts wrongly, my mistake :turned: Thanks for the pausing!! It was really helpful!

Edited by Chivanton, 10 January 2013 - 03:56 AM.

  • 0

#16 J45PER

J45PER

    GMC Member

  • New Member
  • 9 posts
  • Version:GM:Studio

Posted 14 August 2013 - 01:49 PM

 

Is it supposed to zoom in to a particular section of the screen when paused?

Are you using GM: Studio?
I've experienced zooming bugs when copying parts of the screen to a sprite with GM Studio.

so, no, it shouldn't do that normally..
But if you are using studio, it's most likely a bug from Game Maker's side.

This may be a temporary way to bypass it until YoYo fixes the bug:
Spoiler

 

 

I'm just getting an 800x480 view of the top right corner when I build it in Studio and all my rooms are 1280x720 and I don't want to set a fixed screen capture size as it is for Windows 8 so it will scale the resolution.


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users