GameMaker Studio 2 - New Functions List

GameMaker Studio 2 has a major update to the GameMaker Language (GML) and in this article we list all the new functions as well as give a short explanation for each. Some of these are replacement functions for things available previously (like the addition of the GPU functions to replace many of the Texture functions) while the majority are completly new to deal with new functionality in the IDE. You can find out more information about the obsolete functions here, and if you want to port a game from GameMaker: Studio 1.4 we have the following guide: Porting GM:S 1.4 Games Into GameMaker Studio 2.

Array literals

Arrays can now be initialised using the syntax

var a = [1, 2, 3, 4];

Array literals can be used any place where an array could be used like,

show_debug_message( string([1,2,3,4]));

they can also be used to create an empty array as follows

var a = [];

arrays can be nested inside arrays such as

var a = [1,2,[3,4]];

Conditional Operator

Expressions can now use conditional (or ternary) operators, allowing decisions to be made within expressions:

var a = (b == 0) ? 10 : 11

Runtime Changes

Many functions have been added in GameMaker Studio 2, the following sections outline those that have been added and those that have been removed, please consult the manual (Help -> Open Manual) for further info.

Our Windows Desktop Runner has also changed from using DX9 to using DX11 this may mean that there are some compatibility issues that may need to be addressed, there are some known issues at present

No Anti Aliasing implemented - all functions return 0 for the number of anti aliasing levels, we will implement this in the future

Line drawing - unfortunately line drawing is not consistently implemented by hardware vendors, this means that between different manufacturers and different drivers from the same manufacturer you may get different results, we reccomend that you do not rely on line drawing in released games, but the functions are still there for you to try.

Windows XP is no longer supported for games created using GameMaker Studio 2.

gpu_set_blendmode_ext_sepalpha(src,dest,srcalpha,destalpha) - set the gpu blend mode where the source and destination blendmodes are set separately and the src alpha and dest alpha blend modes can be different (each param is one of bm_zero, bm_one, bm_src_colour, bm_inv_src_colour, bm_src_alpha, bm_inv_src_alpha, bm_dest_alpha, bm_inv_dest_alpha, bm_dest_colour, bm_inv_dest_colour, bm_src_alpha_sat)

Resources

sprite_set_speed(ind,speed,type) - set the speed for the sprite and set type spritespeed_framespersecond or spritespeed_framespergameframe

sprite_get_speed_type(ind) - get the speed type for the given sprite

sprite_get_speed(ind) - get the speed for the sprite

Maths

matrix_build_identity() - return an identity matrix

matrix_build_lookat(xfrom,yfrom,zfrom,xto,yto,zto,xup,yup,zup) - builds a "look-at" (view) matrix for a camera at position (xfrom, yfrom, zfrom) and looking at a point (xto, yto, zto) with an up vector of (xup, yup, zup)

matrix_build_projection_ortho(width,height,znear,zfar) - build an orthographic projection matrix with width, height and a z range from znear to zfar

matrix_build_projection_perspective(width,height,znear,zfar) - build a perspective matrix with width, height and a z range from znear to zfar

matrix_build_projection_perspective_fov(fov_y,aspect,znear,zfar)- build a perspective matrix with field of view ange fov_y and an aspect ration and a z range from znear to zfar

matrix_transform_vertex(matrix, x, y, z, [w=1]) - multiply the given vector (x,y,z,w) by the matrix NOTE: if no w component given then it is treated as 1

Tilemaps and Tiles

tilemap_tileset(tilemap_element_id,tileset) - set the tileset to use for the tilemap element

tilemap_x(tilemap_element_id,x) - set the x position of the tilemap element

tilemap_y(tilemap_element_id,y) - set the y position of the tilemap element

tilemap_set(tilemap_element_id,tiledata,cell_x,cell_y) - set the tiledata at the cell (x,y) position on the tilemap element

tilemap_set_at_pixel(tilemap_element_id,tiledata,x,y) - set the tiledata at the pixel (x,y) position on the tilemap element

tilemap_get_tileset(tilemap_element_id) - get the tileset used for the tilemap element

tilemap_get_tile_width(tilemap_element_id) - get the tile width of the tilemap element

tilemap_get_tile_height(tilemap_element_id) - get the tile height of the tilemap element

tilemap_get_width(tilemap_element_id) - get the width (in tiles) of the tilemap element

tilemap_get_height(tilemap_element_id) - get the height (in tiles) of the tilemap element

tilemap_get_x(tilemap_element_id) - get the x position of the tilemap element

tilemap_get_y(tilemap_element_id) - get the y position of the tilemap element

tilemap_get(tilemap_element_id,cell_x,cell_y) - get the tiledata for the cell at (cell_x, cell_y) on this tilemap element

tilemap_get_at_pixel(tilemap_element_id,x,y) - get the tiledata for the pixel at (x, y) on this tilemap element

tilemap_get_cell_x_at_pixel(tilemap_element_id,x,y) - get the cell x for the pixel at (x, y) on this tilemap element

tilemap_get_cell_y_at_pixel(tilemap_element_id,x,y) - get the cell y for the pixel at (x, y) on this tilemap element

tilemap_clear(tilemap_element_id,tiledata) - clear all the cells in the tilemap element with the given tiledata

draw_tilemap(tilemap_element_id,x,y) - draw the tilemap at position x, y in the current view

draw_tile(tileset,tiledata,frame,x,y) - draw the given tiledata from the tileset using given frame at position x, y in the current view

tilemap_set_global_mask(mask) - set the current rendering global mask for ALL tilemap elements (allows user to reserve bits in the tiledata as renderer can be set to ignore them using this function) NOTE:this does not affect get/set tiledata functions above

tilemap_get_global_mask() - get the current global mask

tilemap_set_mask(tilemap_element_id, mask) - set the current rendering mask for this tilemap element (allows user to reserve bits in the tiledata as renderer can be set to ignore them using this function) NOTE:this does not affect get/set tiledata functions above

tilemap_get_mask(tilemap_element_id) - get the current rendering mask

tilemap_get_frame(tilemap_element_id) - get the current frame number for the tilemap element

tile_set_empty(tiledata) - set the tiledata to be an empty cell, returns modified tiledata

tile_set_index(tiledata,tileindex) - set the tileindex to use on a given tiledata, returns modified tiledata

tile_get_index(tiledata) - returns the index of the tile from tiledata

tile_get_flip(tiledata) - returns the flip flag of the tiledata

tile_get_mirror(tiledata) - returns the mirror flag of the tiledata

tile_get_rotate(tiledata) - returns the rotate flag of the tiledata

Instances

instance_activate_layer(layer_id) - activate all instances on the layer

instance_deactivate_layer(layer_id) - deactivate all instance on the layer

instance_create_depth(x,y,depth,obj) - create an instance of obj at position x, y at a specific numeric depth

instance_create_layer(x,y,layer_id_or_name,obj) - create an instance of obj at position x, y on a specific layer (either id or name)

instance_id_get(index) - get an entry from the instance_id array

General Functions

array_equals(var1,var2) - returns true if var1 and var2 are arrays and they are either the same array or an equivalent array

array_create( size, [val], ... ) - create an array of the given size (can be 0), if val argument is passed in then every entry will be set to that value (NOTE: This makes the function slower); if not given then all entries are set to 0.