layer_tilemap_exists

描述

You can use this function to check and see if a tilemap element exists on any given layer. You supply the layer ID (which you get when you create the layer using layer_create()) or the layer name (as a string - this will have a performance impact) and 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 either true if the element exists, or false if it does not.

注意: This function works within the scope of the current target room - by default the room in which the function is called - which can be set using the function layer_set_target_room().


语法:

layer_tilemap_exists(layer_id, tilemap_element_id)


参数:

参数 描述
layer_id The unique ID value of the layer to target (or the layer name as a string)
tilemap_element_id The unique ID value of the tilemap element to check


返回:

Boolean(布尔值)


例如:

var lay_id = layer_get_id("tilemap_trees");
if layer_tilemap_exists(lay_id, global.Treestilemap)
   {
   layer_tilemap_destroy(lay_id, global.Treestilemap);
   }

The above code checks the layer "tilemap_trees" to see if the given tilemap element exists and if it does, then it is destroyed (but not the layer).