background_delete(index);
Argument | Description |
---|---|
index | The index of the background to be deleted. |
Returns: N/A
This function will delete a background from the game, freeing
any memory that was reserved for it. This is a permanent
removal, and if the asset that you delete was included as part of
the game's resources, not even restarting the game (unless you
close the application first) will recover it. This is a very
important function for those moments when you need to create and
change backgrounds from external resources and should always be
used to remove those assets that are no longer needed by a game, or
to clear an indexed asset from a variable before re-assigning
another asset to that same variable.
var bck;
bck = background_create_from_screen(0, 0, 320, 320, false,
false);
background_assign(bck_Custom, bck) background_delete(bck);
The above code creates a local variable and then stores the index of the background created from the screen. This background is then assigned to the asset indexed in the variable "bck_Custom" before being removed from memory again.