BdR Posted December 2, 2016 Share Posted December 2, 2016 Is it possible to change an image key after it's been initiated? When I try the below code, I get no errors but nothing happens. The image "face_a" displays but it doesn't change to "face_b". // preloader game.load.image('face_a', 'face_a.png'); game.load.image('face_b', 'face_b.png'); // create var myimg = game.load.image('face_a'); // some time later myimg.key = 'face_b'; // <- nothing happens, no error no graphics change If I start with "face_b" and then later change key to "face_a" it shows the "face_b" image, so the png images are loaded properly. I've also tried myimg.frame and myimg.frameName but nothing seems to work. Link to comment Share on other sites More sharing options...
stupot Posted December 3, 2016 Share Posted December 3, 2016 Never tried to change an objects's key this way, I use loadTexture to change an existing graphic. BdR 1 Link to comment Share on other sites More sharing options...
BdR Posted December 20, 2016 Author Share Posted December 20, 2016 Thanks, loadTexture that was what I was looking for // some time later myimg.loadTexture('face_b'); Link to comment Share on other sites More sharing options...
Recommended Posts