layer_background_create


Description

With this function you can assign a sprite resource to a layer to be used as a background in your project. 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 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 backgrounds.


Syntax:

layer_background_create(layer_id, sprite)


Arguments:

Argument Description
layer_id The unique ID value of the layer to target (or the layer name as a string)
sprite The sprite index to be used


Returns:

Background element ID (Real)


Example:

global.back_layer = layer_create(10000);
global.back_trees = layer_background_create(global.back_layer, spr_Trees);

The above code creates a new layer and then adds a new background element to it, setting a sprite to be the background image used.


Back: Background Layer Functions
next: layer_background_destroy
© Copyright YoYo Games Ltd. 2018 All Rights Reserved