- Title: Easy pause tutorial
- Description: I'll show you how to make a script which pauses the game when you press a key (without saving files). An additional pause menu or anything else is very easy to build in.
- GM Version: GM 7 / 8
- Registered: No
- File Type: .txt and .gmk
- File Size: 28Kb
- File Link: Pause_menu.txt, Pause_example.gmk
Follow the instructions and it should work perfectly.
This is what you have to do:
1. Create an object named obj_pausecontroller and place this piece of code in the Draw Event.
if room = rm_pause
{
draw_background(global.pausebg,0,0)
}2. Place this script in the Step Event.
//////////////// Pause menu script ///////////////
//
// Made by Maurits van der Veen
// Simau Games © December 14, 2010
//
// You're free to use this script, credits are appreciated =D
//
// Need help? Please feel free to contact me: Mauriits@gmail.com.
//////////////////////////////////////////////////
room_persistent = 0 //only needed if your rooms are not presistent
if keyboard_check_pressed(ord("P"))
{// of course ord("P") can be replaced by the key you want
if room != rm_pause
{
global.varprevroom = room;
room_persistent = 1; //only needed if your rooms are not presistent
global.pausebg = background_create_from_screen(0,0,argument0,argument1,0,0);
room_goto(rm_pause);
}
else
{
background_delete(global.pausebg);
global.pausebg = 0;
room_goto(global.varprevroom);
}
}3. The depth of obj_pausecontroller has to be lower than all other objects (e.g. -2000000).
4. Create a new room and call it rm_pause, give it the same width and height as the views in the other rooms (if you aren't using views; use the same width and height as the other rooms).
5. Place the obj_pausecontroller in rm_pause and in every room where you want the player to be able to pause the game.
6. Replace argument0 with the width of rm_pause and argument1 with the height of rm_pause. (Line 19 of the script which has to be placed in the Step Event)
7. Everything you want, when the game is paused can be made in rm_pause.
8. It should work now, have fun with it!
If you have any questions, comments or if you need help, feel free to contact me (Mauriits@gmail.com) or post a reply.
Edited by Mauriits, 24 February 2012 - 06:26 PM.











