Using this function you can retrieve the y-axis position of an individual tilemap cell by giving the relative y-axis position within the room. 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()), as well as the x and y position within the room and the function will return the y position of the cell within the tilemap for that point. Note that if the value is outside of the tilemap area, and no cell is available, it will return -1.


tilemap_get_cell_y_at_pixel(tilemap_element_id, x, y);


Argument Description
tilemap_element_id The unique ID value of the tilemap element to get the cell y position of
x The x position within the room to use for getting the cell
y The y position within the room to use for getting the cell


Integer (y-axis cell position or -1 if there is an error)


var lay_id = layer_get_id("Tiles_Walls");
var map_id = layer_tilemap_get_id(lay_id);
var _x = tilemap_get_cell_x_at_pixel(map_id, mouse_x, mouse_y);
var _y = tilemap_get_cell_y_at_pixel(map_id, mouse_x, mouse_y);
tiledata = tilemap_get(map_id, _x, _y);

The above code uses the retrieved tilemap ID to get the cell position from a set of room coordinates and then store the data for any tile found there in an instance variable.