This function can be used to destroy all the instances 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 then all instances that are on the layer will be removed from the game, triggering their Destroy and Clean Up events.
layer_destroy_instances(layer_id)
| Argument | Description |
|---|---|
| layer_id | The unique ID value of the layer to set the depth of (or the layer name as a string) |
Real (Unique ID value for an instance)
if global.game_over
{
layer_destroy_instances(layer);
}
The above code will check a global variable and if it's true then all instances that are on the layer of the calling instance will be destroyed (including the calling instance).