With this function you can assign a sprite resource to a layer to be used in your project. You supply the layer ID (which you get when you create the layer using layer_create() or when you use the layer name along with layer_get_id()), a position within the room, and a sprite index (which would be the name of the sprite as shown in the resource tree), and it will be added to the layer. The function returns the unique ID value for the element, which can then be used in further layer functions for sprites.
layer_sprite_create(layer_id, x, y, sprite)
Argument Description layer_id The unique ID value of the layer to target x The x position to use y The y position to use sprite The sprite index to be used
Sprite element ID (Real)
global.asset_layer = layer_create(10000);
for (var i = 0; i< 10; i++;)
global.asset_spr_trees[i] = layer_sprite_create(global.asset_layer, random(room_width), room_height - 100, spr_Trees);
The above code creates a new layer and then adds 10 new sprite elements to it, storing the ID of each element to an array.