· ·

How to Use Alarms in GameMaker

Learn how to schedule actions using alarms in GameMaker

What Is an Alarm?

Imagine you’re baking a pizza.

You put it in the oven, set a timer, and walk away.
When the timer goes off, it’s time to take the pizza out.

GameMaker alarms work the same way.

They let you say:

“Hey GameMaker, wait this many steps, then do something.”

Why Use Alarms?

Sometimes you don’t want something to happen right away. Alarms are great for doing something after some time has passed.

Think about how games might use alarms:

Alarms make things like this easy.

How Alarms Work

Try It Out!

Click on the alarm clock to activate it! When it reaches 0, it’ll shake. After an alarm expires, it’ll be set to -1. The clockface shows the value of alarm[0] each step!

More Examples

Let’s say you want something to happen after 2 seconds.
If your game runs at 60 FPS, that’s 120 steps.

💡 Create Event:

alarm[0] = 120;

Alarm 0 Event:

show_message("Time's up!");

Now, when the object is created, GameMaker waits 120 steps, then shows the message.

Looping with Alarms

Want to make something happen every second? We’ll set an alarm as an instance is created, and then we’ll reset the alarm in the alarm event!

💡Create Event:

alarm[0] = 60;

Alarm 0 Event:

alarm[0] = 60;

It sets itself again — a simple timer loop!

Common Mistakes

Summary

What’s Next?