File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1667,26 +1667,30 @@ Phaser.Cache.prototype = {
16671667 } ,
16681668
16691669 /**
1670- * Removes an image from the cache and optionally from the Pixi.BaseTextureCache as well.
1670+ * Removes an image from the cache.
1671+ *
1672+ * You can optionally elect to destroy it as well. This calls BaseTexture.destroy on it.
16711673 *
1672- * Note that this only removes it from the Phaser.Cache . If you still have references to the data elsewhere
1674+ * Note that this only removes it from the Phaser and PIXI Caches . If you still have references to the data elsewhere
16731675 * then it will persist in memory.
16741676 *
16751677 * @method Phaser.Cache#removeImage
16761678 * @param {string } key - Key of the asset you want to remove.
1677- * @param {boolean } [removeFromPixi=true] - Should this image also be removed from the Pixi BaseTextureCache?
1679+ * @param {boolean } [removeFromPixi=true] - Should this image also be destroyed? Removing it from the PIXI. BaseTextureCache?
16781680 */
16791681 removeImage : function ( key , removeFromPixi ) {
16801682
16811683 if ( removeFromPixi === undefined ) { removeFromPixi = true ; }
16821684
1683- delete this . _cache . image [ key ] ;
1685+ var img = this . getImage ( key , true ) ;
16841686
1685- if ( removeFromPixi )
1687+ if ( removeFromPixi && img . base )
16861688 {
1687- PIXI . BaseTextureCache [ key ] . destroy ( ) ;
1689+ img . base . destroy ( ) ;
16881690 }
16891691
1692+ delete this . _cache . image [ key ] ;
1693+
16901694 } ,
16911695
16921696 /**
Original file line number Diff line number Diff line change @@ -164,13 +164,16 @@ PIXI.BaseTexture.prototype.destroy = function()
164164 {
165165 delete PIXI . BaseTextureCache [ this . imageUrl ] ;
166166 delete PIXI . TextureCache [ this . imageUrl ] ;
167+
167168 this . imageUrl = null ;
169+
168170 if ( ! navigator . isCocoonJS ) this . source . src = '' ;
169171 }
170172 else if ( this . source && this . source . _pixiId )
171173 {
172174 delete PIXI . BaseTextureCache [ this . source . _pixiId ] ;
173175 }
176+
174177 this . source = null ;
175178
176179 this . unloadFromGPU ( ) ;
You can’t perform that action at this time.
0 commit comments