ptdnet Posted February 18, 2015 Share Posted February 18, 2015 So let's say I do something like ...game.load.image("dude", "/some/image/here.png");// do a bunch of stuff...game.load.image("dude", "/other/image/here.png");What happens to the first image I loaded? Is it leaked? Destroyed properly? I tried looking in the Phaser code but can't tell exactly. Link to comment Share on other sites More sharing options...
rich Posted February 18, 2015 Share Posted February 18, 2015 Depends when you load it. If you do this in the same preload block, then the 2nd call will be ignored unless you set the overwrite parameter to true:game.load.image("dude", "blah.png", true);If you do this some time later, i.e. in another State, then it will replace whatever was in the image cache matching that ID, but the original image object is left un-touched. Under Phaser 2.3 if this happens the original image is destroyed first and removed from the GPU. drhayes and mariogarranz 2 Link to comment Share on other sites More sharing options...
ptdnet Posted February 18, 2015 Author Share Posted February 18, 2015 Yeah the second load would definitely be outside the preload block. So it sounds like once 2.3 hits then I essentially don't have to worry about the first one; I want it to be destroyed. Thanks! Link to comment Share on other sites More sharing options...
AmAuron Posted June 1, 2015 Share Posted June 1, 2015 Depends when you load it. If you do this in the same preload block, then the 2nd call will be ignored unless you set the overwrite parameter to true:game.load.image("dude", "blah.png", true);If you do this some time later, i.e. in another State, then it will replace whatever was in the image cache matching that ID, but the original image object is left un-touched. Under Phaser 2.3 if this happens the original image is destroyed first and removed from the GPU.One more question related to this issue...imagine that you have 2 states...one of them has something like this: Previous State (Preload state)//this.listofimages is an array of locations of images//this.imagearray is an array that countains the numbers of the images that i must loadpreload: function(){ //loading of sound before while(this.i<5) { this.load.image('lvl1'+ this.i, 'assets/images/biblioteca/'+this.listofimages.imagens[this.imagearray[this.i]].imagem+'.jpg', true); console.log('assets/images/biblioteca/'+this.listofimages.imagens[this.imagearray[this.i]].imagem); this.i++; }},update: function(){ if(this.cache.isSoundDecoded('fundosong') && this.ready == true) { this.state.start('Game', true, false, this.listofimages, this.imagearray); }}Next State (Game state)create: function(){ this.imagem = this.add.image(this.game.world.centerX, this.game.world.centerY-200, 'lvl1'+this.counter); this.imagem.x = this.game.width/2 - 150;}basicly the 2nd time the images won't change....even with overwrite?If so how can i get arround this...and can i apply the same logic for sounds too? Thank you for your time to answer this question. Link to comment Share on other sites More sharing options...
Recommended Posts