background_duplicate

Creates a duplicate of the background with the given index.

Syntax:

background_duplicate(index);


Argument Description
index The index of the background to duplicate.


Returns: Real


Description

This function will return the index of a newly created background that is a duplicate (copy) of the one input as the "index" argument. If the function fails, -1 is returned.

NOTE: When you duplicate a background in GameMaker: Studio you must remember to remove it again (with background_delete) when no longer needed, otherwise there is risk of a memory leak which will slow down and eventually crash your game.


Example:

new_bck = background_duplicate(background_index[0])

The above code duplicates the background currently being used as the background index of the current room and stores the index for this new background in the variable "new_bck".


Back: Backgrounds
Next: background_assign
© Copyright YoYo Games Ltd. 2018 All Rights Reserved