GameMaker: Studio

GameMaker: Studio

View Stats:
vgreeson Jan 4, 2014 @ 5:41pm
Where is the "sleep" equivalent?
Surely, at least in GML, there's a command to do nothing for a period? All I've found so far is that there was a sleep function in 8.1 but not in studio....
< >
Showing 1-7 of 7 comments
Bruford Jan 4, 2014 @ 6:51pm 
I use instance_deactivate_all();
and then
instance_reactivate_all();
when I'm done with the pausing.

If you want the screen to remain unchanged you can take a snaphot of it as a surface and display that surface as a sprite (but I've never done this 'cos i'm only learning surfaces now for the first time).
Last edited by Bruford; Jan 4, 2014 @ 6:51pm
Sera Jan 4, 2014 @ 7:30pm 
I believe sleep was removed because most of the target OSs found the function to be malicious, but I could be mistaken.

An alternative to Bruford's solution would be to disable the drawing of a background color and any other nackground objects on top of deactivating everything; as I recall, that should stop the room from having anything to redraw and thus just leave the canvas as it was when you left it until you change things back, but tileset layers could complicate this so the stated method might be one of the more solid ways to approach this.

Another thing I've looked into was having a global Pause variable and start every bit of applicable code with a check to make sure the game should be running, but this renders GM's built in alarms, timelines and to a lesser extent paths a fair bit useless, so use that with caution as well.
vgreeson Jan 4, 2014 @ 9:06pm 
I thought to set up a loop that does nothing but count down time, but that sort of operates outside game time, I think...

(Something like
var future_time = current_time + 1000; while current_time < future_time {}
but using system time.)

All I want is a delay between events. I do appreciate the suggestions, though. I'm just surprised nothing more straightforward is built in. apparently it was in 8 and earlier...

Last edited by vgreeson; Jan 4, 2014 @ 9:09pm
forwardresent Jan 4, 2014 @ 10:03pm 
This may work, but I haven't tested it. Use an alarm system.

In your pause event/trigger:

instance_deactivate_all(true) // The true here is whether the object it is attached to should be excluded from deactivation. If it is true it will stay active, if it is false it will be deactivated.

alarm [ 0 ] = ? // (However long you want it to pause in frames. If your room speed is 30, 1 second is 30 frames)

in the Alarm [ 0 ] event:
instance_reactivate_all();

Sleep was removed because it forced the runner to freeze and become unresponsive.
Last edited by forwardresent; Jan 4, 2014 @ 10:08pm
vgreeson Jan 4, 2014 @ 11:07pm 
Thanks to everyone! I will try the deactivate / alarm aproach, and come back if I encounter anything interesting. (It working isn't "interesting", so no news is good news.) Thanks very much again!
08jack May 10, 2016 @ 5:53pm 
Lol, I just set the room_speed down to 15 and set an alarm for like, 1 step which will set room_speed back to 30.

I know it's lame but it works.
sitebender May 10, 2016 @ 6:15pm 
We need to gather the knights. There's a necromancer in the forum.
< >
Showing 1-7 of 7 comments
Per page: 1530 50

Date Posted: Jan 4, 2014 @ 5:41pm
Posts: 7