You can use this function to check and see if a background 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 background element ID (which you get when you create a background element using layer_background_create() or when you use the function layer_background_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_background_exists(layer_id, background_element_id)


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




var lay_id = layer_get_id("Background_trees");
if layer_background_exists(lay_id, global.TreesBackground)
   layer_background_destroy(lay_id, global.TreesBackground);

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

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