diff --git a/README.md b/README.md index f8d7880af..edf579f0f 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ Version 2.1.2 - "Whitebridge" - in development ### New Features * StateManager.unlink will null all State-level Phaser properties, such as `game`, `add`, etc. Useful if you never need to return to the State again. +* Cache.removeImage has a new parameter: `removeFromPixi` which is `true` by default. It will remove the image from the Pixi BaseTextureCache as well as from the Phaser Cache. Set to false if you don't want the Pixi cache touched. ### Updates diff --git a/src/loader/Cache.js b/src/loader/Cache.js index d8a914a05..c1ece40e3 100644 --- a/src/loader/Cache.js +++ b/src/loader/Cache.js @@ -1215,13 +1215,23 @@ Phaser.Cache.prototype = { }, /** - * Removes an image from the cache. + * Removes an image from the cache and optionally from the Pixi.BaseTextureCache as well. * * @method Phaser.Cache#removeImage * @param {string} key - Key of the asset you want to remove. + * @param {boolean} [removeFromPixi=true] - Should this image also be removed from the Pixi BaseTextureCache? */ - removeImage: function (key) { + removeImage: function (key, removeFromPixi) { + + if (typeof removeFromPixi === 'undefined') { removeFromPixi = true; } + delete this._images[key]; + + if (removeFromPixi) + { + PIXI.BaseTextureCache[key].destroy(); + } + }, /**