tilemap_get_width

Description

Using this function you can retrieve the width (in cells) of the tilemap element. You give the tilemap element ID (which you get when you create a tilemap element using layer_tilemap_create() or when you use the function layer_tilemap_get_id()), and the function will return the width (number of cells wide).


Syntax:

tilemap_get_width(tilemap_element_id);


Arguments:

Argument Description
tilemap_element_id The unique ID value of the tilemap element to get the width of


Returns:

Integer


Example:

var lay_id = layer_get_id("Tiles_Walls");
var map_id = layer_tilemap_get_id(lay_id);
var _w = tilemap_get_width(map_id);
var _h = tilemap_get_height(map_id);
total_tiles = (_w * _h);

The above code uses the retrieved tilemap ID to get the tile width and height of the tilemap and then uses those values to set an instance variable.