layer_has_instance


Description

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.


Syntax:

layer_has_instance(layer_id, instance_id)


Arguments:

Argument Description
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


Returns:

Boolean


Example:

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.


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