mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 12:43:26 +00:00
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:
parent
6c04d99039
commit
d5cd37a9ac
1 changed files with 29 additions and 0 deletions
|
@ -177,6 +177,35 @@ var Texture = new Class({
|
|||
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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue