layer_get_all_elements


描述

You can use this function to get the element IDs of the 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 function will return an array of IDs, where each entry in the array is a unique ID for an element on that layer. For example, if the layer is an Asset Layer, the array will be populated with the ID values for each sprite asset that is assigned to the layer. Note that using code to work with layers means that you can assign different element types to the same layer - so you can have sprite assets along with instances, for example - in which case you can then use the function layer_get_element_type to get the type of element the ID relates to.


语法:

layer_get_all_elements(layer_id)


参数:

参数 描述
layer_id The unique ID value of the layer to get the elements from (or the layer name as a string)


返回:

Array (1D, populated with Element IDs)


例如:

var a = layer_get_all_elements(layer);
for (var i = 0; i < array_length_1d(a); i++;)
   {
   if layer_get_element_type(a[i]) == layerelementtype_sprite
      {
      layer_sprite_destroy(a[i])
      }
   }

The above code gets the IDs for all the instance elements assigned to the layer of the instance running the code. The code then checks to see if any of the returned elements are sprite assets and if they then they are destroyed.


上一页: General Layer Functions
next: layer_get_element_layer
© Copyright YoYo Games Ltd. 2018 All Rights Reserved