layer_has_instance


描述

This function can be used to check if a given instance is currently assigned to 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 instance ID of the instance to check for. You can also give an object_index (ie: the name of the object in the resource tree) and the function will check if any instances of that object are on the given layer. The function will return true if the instance is on the layer and false if it is not.


语法:

layer_has_instance(layer_id, instance_id)


参数:

参数 描述
layer_id The unique ID value of the layer to target (or the layer name as a string)
instance_id The unique instance ID or the object index of the instance to check for


返回:

Boolean(布尔值)


例如:

if !layer_has_instance(global.Bullet_Layer, obj_Bullet_Parent)
   {
   layer_destroy(global.Bullet_Layer);
   }

The above code will check to see if the given layer contains any instances of the object "obj_Bullet_Parent" and if not it will destroy the layer.


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