
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:
- Make an enemy wait 2 seconds before attacking
- Show a message for a few seconds and then hide it
- Make something flash, disappear, or come back after a delay
Alarms make things like this easy.
How Alarms Work
- Every object in GameMaker has 12 alarms:
alarm[0]throughalarm[11] - You set an alarm to a number of steps (1 step = 1 frame)
- GameMaker counts down every step
- When it reaches 0, it runs that object’s Alarm Event for that alarm.
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
- Don’t forget to set the alarm again if you want it to repeat.
- Alarms are per object, so setting
alarm[0]on one instance won’t affect others. - If the object is destroyed before the alarm finishes, the alarm won’t run.
Summary
- Alarms are like countdown timers.
- You give them a number of steps to wait.
- They trigger an Alarm Event when time’s up.
- They’re great for delays, cooldowns, spawns, effects, and more.
What’s Next?
- Looking for more control over the timing in your game? Read up on Time Sources.
