Texture.remove is a new method that allows you to remove a Frame from a Texture based on its name. Fix #4460

This commit is contained in:
Richard Davey 2019-08-07 13:03:00 +01:00
parent 6c04d99039
commit d5cd37a9ac

View file

@ -177,6 +177,35 @@ var Texture = new Class({
return frame; return frame;
}, },
/**
* Removes the given Frame from this Texture. The Frame is destroyed immediately.
*
* Any Game Objects using this Frame should stop using it _before_ you remove it,
* as it does not happen automatically.
*
* @method Phaser.Textures.Texture#remove
* @since 3.19.0
*
* @param {string} name - The key of the Frame to remove.
*
* @return {boolean} True if a Frame with the matching key was removed from this Texture.
*/
remove: function (name)
{
if (this.has(name))
{
var frame = this.get(name);
frame.destroy();
delete this.frames[name];
return true;
}
return false;
},
/** /**
* Checks to see if a Frame matching the given key exists within this Texture. * Checks to see if a Frame matching the given key exists within this Texture.
* *