9 Types of Events in GameMaker: Studio

By Michael Rohde

Events in GameMaker: Studio are things you add to your game to control the action the player has. Here are nine types of events you can use in games that you make in GameMaker: Studio.

The destroy event

Use the Destroy Event when you no longer want an Instance in the Room — say, when an enemy gets blown up. You can use the Destroy Event to trigger an explosion, increase the player’s score, or re-create a new Instance of the Object (or all three).

This figure shows an Object with a Destroy Event with a Set Score Action. This obviously isn’t a fully configured enemy Object — you would want the Destroy Event to be the last, and certainly not the only, Event.

Use the Destroy Event to increase the player’s score.

Use the Destroy Event to increase the player’s score.

The alarm event

You can add up to 12 Alarms for each Instance in the Room. Alarms are excellent for when you want to time Actions. For example, if you want the player to only shoot bullets once every two seconds, you can set an Alarm for that. If you want to time when new enemy planes appear, you can set an Alarm for that as well.

To get an Alarm to work, you must first set an Alarm Action to trigger the Alarm Event after a countdown that you set. In that way, Alarms enable you to time when events happen in your game.

An Instance is an Object that you’ve placed in the Room. You can place more than one Instance of an Object in a Room, so you can have multiple Instances of the same Object in your game.

The step event

Step Events are great for when you want something to continuously happen, or you want something continuously checked for each step of the game. GameMaker tells time by steps, which is defined by the Room Speed, which sets how many steps are performed each second.

An example of using a Step Event is to determine if certain Instances have left the Room, and if so, to reappear at the top of the Room. As GameMaker needs to continuously check to see if the Instance left the Room, a Step Event comes in very handy to use.

The collision event

If your game has Instances flying every which way and collisions are inevitable, then you may be using a lot of Collision Events. These Events are great for when you want something to happen when two Instances collide — such as when a bullet Instance hits a plane Instance or, more simply, when a player Instance hits a wall Instance and you want the player to bounce off the wall.

Masks are important to Collision Events because this is how GameMaker determines where the actual collision takes place.

The mouse event

Mouse Events can be as simple as assigning the left button to fire, but there is a large submenu of Events that you can choose from. This figure also shows the tertiary menu for Global mouse.

In this way, GameMaker provides you great control over how you want the mouse to behave in your game. After you choose which Mouse Event you want to use, you can add Actions to that event or even your own code.

The many options for the Mouse Event.

The many options for the Mouse Event.

The other event

Ah, the Others. Those not deemed worthy of their own place on the Event menu. These Other Events can be kinda awesome. The menu items are pretty much self-explanatory, so details on them are not needed here. For full descriptions of each of these items, you can always press F1 within the GameMaker and search for Events.

The draw event

Use the Draw Event when you want to display something during the game. The Draw Event does have its own submenu, as shown in this figure.

If you use a Draw Event, GameMaker no longer defaults to the assigned Sprite, and instead you have to tell GameMaker what to draw.

The Draw Event submenu.

The Draw Event submenu.

The key events

When you click Add Event, you may notice there are three different options for the keyboard: Keyboard, Key Press, and Key Release. Use the Key Press and Key Release Events to trigger an Action once each time an assigned key is pressed or released. The Keyboard Event is good for when the player needs to press the key continuously, such as for moving an Instance across the Room.

Each of the Key Events has a submenu, as shown in the figure, from which you can assign a key for the Action. Use <Left>, <Right>, and so on for the arrow keys on the keyboard.

The Keyboard has many options to fit your many needs.

The Keyboard has many options to fit your many needs.

The asynchronous event

The Asynchronous Event is triggered at the end of another Action, such as the loading of a file or a reply from a web server. This Event also has a submenu, as shown here.

The Asynchronous Event triggers after another Action finishes.

The Asynchronous Event triggers after another Action finishes.

Asynchronous Events are triggered by functions that need to receive data from a source at an unknown time in the future. This Event is best used for seasoned game developers who are creating complex online games.