background_replace

Replace a background resource with another one.

Syntax:

background_replace(ind, fname);


Argument Description
ind The index of the background to permanently replace.
fname The filename of the image to make the new background.
removeback Indicates whether to make all pixels with the same colour (left-bottom pixel) transparent.
smooth Indicates whether to smooth the edges.


Returns: N/A


Description

This function works in almost the exact same manner as background_add, only instead of returning the index of the background you are importing, it overwrites a previously created background index. The background index to be replaces is one that has been created and stored in a variable using other functions like background_add or background_create_from_surface. You can not use one from the resource tree as you cannot replace built-in assets.

NOTE: Depending on the target platform that is chosen you are limited as to where you can save and load files from. See Reference - Files for more information.

NOTE: You should be aware that if you are using this function in your HTML5 target game to load resources from an external server, then, due to XSS protection in browsers, attempts to load resources from across domains can be blocked and may appear to return blank results.




Example:

background_replace(bck_Sky, "Sky_5.png");

The above code will replace the image asset indexed in "spr_Sky" with another one loaded from an external source.


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