GameMaker Studio 2 Language Reference


This section of the manual is a reference guide for the GameMaker Studio 2 Language (GML). You can find all the available functions documented here along with the required arguments and examples of code to show how they can be used. For information on how to use GML please see the GML Overview section of the manual.

The following sections explain the functions that you have available to you for manipulating the different resources in your project, including creating new dynamic resources or editing and changing those that are added into your game through the resource tree.

Sprites

  1. General Sprite Functions
  2. Skeleton Animation Sprites

Audio

  1. General Audio Functions
  2. Audio Emitters
  3. Audio Listeners
  4. Audio Groups
  5. Audio Buffers
  6. Audio Synchronisation

Paths

  1. General Path Functions
  2. Changing Paths
  3. Path Information

Scripts


Shaders

  1. Shader Functions
  2. Shader Constants

Fonts


Timelines


Objects

  1. General Object Functions
  2. Generating Events

Instances

  1. Instance Variables
  2. Instance Functions
  3. Deactivating Instances

Rooms

  1. General
  2. Layers
  3. Backgrounds
  4. Sprites
  5. Tilemaps

There are two extra functions related to the handling of game resources. These functions can be used to find the unique index value for any given resource and the type of resource that it is, which opens the door to dynamically creating game resources from strings (for example):


This section contains the functions and variables that are all related to game specific functionality, like loading/saving or restarting etc...


GameMaker Studio 2 has a great number of ways in which you can move instances around within your game room, ranging from setting speed and direction vectors to simply "placing" an instance at a specific position, as well as using more sophisticated methods like path-finding. There are also a good number of different methods for detecting collisions between two instances, and which you choose will depend largely on the type of game you are making and the exact situation that you need to use the collision functions in. The following sections cover all of this and list all the functions related to movement, path-finding and collisions:

Movement


Motion Planning


Collisions



The following sections are all related to graphics operations in one way or another, whether it is drawing something to the screen, manipulating surfaces, or creating your own cameras or vertex formats:

Colour


GPU Control


Drawing Basic Forms


Drawing Sprites And Tiles


Drawing Text


Drawing And Creating Primitives


Surfaces


Particles


Textures


Shaders


The following sections contain all the functions and built in variables that are used for setting up view cameras, view ports and the game window, as well as setting the GUI display for your game projects.

Cameras


The Screen Display



There are a number of different ways that you can let players control things ion your game, from using the keyboard and mouse to creating virtual keys or using the gamepad, and they are all listed in the following sections:

Keyboard Input


Mouse Input


Device Input


Gesture Input


Gamepad Input


Virtual Keys And Virtual Keyboards



Data structures are basically different ways that you can store large amounts of data. Which one you use will depend entirely upon the needs of the situation and you should read the introduction page of each section to get a better idea of how they work and when they can be used:

Data Structures


DS Stacks


DS Queues


DS Lists


DS Maps


DS Priority Queues


DS Grids



The following sections list the functions for working with instance and global variables as well as for working with arrays (note that the variable functions are designed to be used when converting DnD™ code to GML code or for use in compatibility scripts more than for general use in new projects):

Variable Functions


Array Functions



The following sections contain all the functions and built in variables that are used for working with strings:

Strings



The following sections contain all the functions and built in variables that are used for working with different number values:

Date And Time


Number Functions


Vectors


Matrix Functions



The following sections all deal with different aspects of the GameMaker Studio 2 Box 2D physics implementation:

Physics Overview


The Physics World


Fixtures


Joints


Forces


Soft Body Particles


Physics Variables



The following section has all the functions related to the In App Purchase system (note that these functions work in conjunction with the IAP Asynchronous Event):

In App Purchases



The following sections have a collection of functions that all work with, or trigger, the Asynchronous Events, including the HTTP functions, Cloud functions and a few others:

Asynchronous Functions


Facebook


Achievements and Leaderboards



This section has all the functions related to creating networked games (ie: games that communicate with each other over the internet):

Networking



This section has functions specific to creating HTML5 web applications as well as a few more general web functions for opening URLs etc...

Web



GameMaker Studio 2 is fully integrated with the Steamworks API so that you can create your games with that platform in in mind, and integrate the different services that it offers from day one of development. See the sections below for more information:

The Steam API


Steam User Generated Content



While making a game you will, at some point, need to store information about the game state to a file. To that end, GameMaker Studio 2 has a number of different functions for this, enabling you to read and write data to various different file types:

File System Overview


File Handling


File System Functions


INI Files


Text Files


Binary Files



Buffers enable you to directly access areas of memory, adding, removing and saving information as raw data. Below you can find a detailed explanation of what buffers are and how to use them as well as all the functions related to them:

Using Buffers


Buffers



The functions in this section are specifically for use with the UWP target, and then only when using UWP to target the Xbox One. The functions give you basic access to XBox Live features:

UWP and Xbox Live



This section contains a number of functions that are for doing very specific things when creating your game and that don't fit exactly into any of the other function groups on this page:

Miscellaneous



Debugging your code is an essential part of making games and apart from the tools provide by GameMaker Studio 2 (like the Debug Module), there are also a few extra functions to help you:

Debugging



Please note that there are certain functions that have been added to the IDE which will show up only in the compatibility scripts when you import a game made with a previous version of GameMaker Studio. These functions should not be used and are only designed for compatibility. The following section of the manual lists these functions so that if you see them you know what they are, but please avoid using them in your projects: