tilemap_set_at_pixel

描述

This function can be used to set a cell within the tilemap element on the layer to a new tile using the actual position of the tile to change 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()), and then the tile data to set as well as the position within the room. You can retrieve tile data using the function tilemap_get_at_pixel and then use the tile_ functions to change it before setting it again using this function. The function will return true if the tile was successfully set and false if there was an issue and it wasn't set.


语法:

tilemap_set_at_pixel(tilemap_element_id, tiledata, x, y)


参数:

参数 描述
tilemap_element_id The unique ID value of the tilemap element to change
tiledata The tile set data to set
xcell The x position (in the room)
ycell The y position (in the room)


返回:

Boolean(布尔值)


例如:

var lay_id = layer_get_id("Tiles_sky");
var map_id = layer_tilemap_get_id(lay_id);
var data = tilemap_get_at_pixel(map_id, 4, 4);
data = tile_set_flip(data, true);
tilemap_set_at_pixel(map_id, data, 4, 4);

The above code gets the ID for the tilemap on the layer "Tiles_Sky" and then uses that to get the data from the tile at position (4, 4). This tile data is then flipped before being used to set the tile on the tilemap again.