• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

"Wait" command?

S

SendTheGravy

Guest
Hi. I'm super new to programming and was just wondering if there is a "wait" command when programming. I want to have a pause between a sprite change on an object, how would I go about doing that, thanks! :)
 

Slyddar

Member
All lines in Gamemaker are processed sequentially as fast as your processor can handle them. There is no "wait" command as such, so you need to manually set up any waiting by either using a variable or one of the 12 alarms each object has.

Setting an alarm allows something to happen after a period of time. You set the alarm with something like alarm[0] = 60 and then create an alarm event, and add your code that you want to run in that event. The alarm will countdown and that code will run.

The other method is you can set up a variable to do something after a certain amount of time.
eg.
CREATE event - Initialise the variable
Code:
myalarm = 0;
You then set myalarm to some value at some point, and have this in the step event of the object.

STEP - check if the alarm should run
Code:
//Step event
if (myalarm > 0) {
    myalarm -= 1;
    if (myalarm <= 0) {
        // code you want to run
    }
}
You can even write the step event shorter like this, which uses the ! not command, and -- to take one off myalarm each pass.
Code:
if (myalarm and !--myalarm ) {
    // code you want to run
}
 

TheouAegis

Member
They got rid of wait because it caused a loop that some OSes were not compatible with. If you loop for too long, the OS may interpret it as a timeout and close the program.
 
Top