Im trying to change the background image of a game built using pixijs. Im just wondering what is the best way to do it ?. Currently im using the below method but the problem is i have to redraw all the other child elements after i change the background. Thank you
const parent = app.view.parentNode;
var imagePath = "images/"+image;
var landscapeTexture = PIXI.Texture.fromImage(imagePath);
var texture2 = new PIXI.Texture(landscapeTexture, new PIXI.Rectangle(0, 0, parent.clientWidth, parent.clientHeight));
background = new PIXI.Sprite(texture2);
Thanks for replying. Sorry if its not clear. Let me explain further.
Im creating a simple jigsawpuzzle game and Im following the method explained in below thread .
Now i want to add a background to the game. For that im using the method i have explained in the post. My problem is, whenever i change the background image i also have to redraw the puzzle pieces again. So im wondering is there a better way to do this where i can just change the background layer without having to redraw all the pieces ?