This function can be used to check whether a given set of tiledata is for an empty tile or not. You give the tiledata, which can be retrieved using the function tilemap_get, and the function will return true if the tile is empty, or false if there is a tile index.
tile_get_empty(tiledata)
参数 描述 tiledata the tiledata to check
Boolean(布尔值)
var lay_id = layer_get_id("Tiles_sky");
var map_id = layer_tilemap_get_id(lay_id);
for (var i = 0; i < tilemap_get_width(map_id); i++;)
{
for (var j = 0; j < tilemap_get_height(map_id); j++;)
{
var data = tilemap_get(map_id, i, j);
if !tile_get_empty(data)
{
data = tile_set_empty(data)
tilemap_set(map_id, data, i, j);
}
}
}
The above code gets the tilemap ID from the given layer and then proceeds to check every tile cell on the map to see if it has data or not. If it does, the tile is set to empty.