mirror of
https://github.com/photonstorm/phaser
synced 2024-11-16 01:38:23 +00:00
Removed use of UUID from RenderTexture and fixed saveTexture method.
This commit is contained in:
parent
57f2f7abd7
commit
b318cd734f
2 changed files with 29 additions and 12 deletions
|
@ -7,7 +7,6 @@
|
|||
var Class = require('../../utils/Class');
|
||||
var DynamicTexture = require('../../textures/DynamicTexture');
|
||||
var Image = require('../image/Image');
|
||||
var UUID = require('../../utils/string/UUID');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
|
@ -71,9 +70,7 @@ var RenderTexture = new Class({
|
|||
if (width === undefined) { width = 32; }
|
||||
if (height === undefined) { height = 32; }
|
||||
|
||||
var key = UUID();
|
||||
|
||||
var dynamicTexture = new DynamicTexture(scene.sys.textures, key, width, height);
|
||||
var dynamicTexture = new DynamicTexture(scene.sys.textures, '', width, height);
|
||||
|
||||
Image.call(this, scene, x, y, dynamicTexture);
|
||||
|
||||
|
@ -169,15 +166,20 @@ var RenderTexture = new Class({
|
|||
*
|
||||
* @param {string} key - The unique key to store the texture as within the global Texture Manager.
|
||||
*
|
||||
* @return {Phaser.Textures.Texture} The Texture that was saved.
|
||||
* @return {Phaser.Textures.DynamicTexture} The Texture that was saved.
|
||||
*/
|
||||
saveTexture: function (key)
|
||||
{
|
||||
this.textureManager.renameTexture(this.texture.key, key);
|
||||
var texture = this.texture;
|
||||
|
||||
this._saved = true;
|
||||
texture.key = key;
|
||||
|
||||
return this.texture;
|
||||
if (this.textureManager.addDynamicTexture(texture))
|
||||
{
|
||||
this._saved = true;
|
||||
}
|
||||
|
||||
return texture;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -722,13 +722,16 @@ var TextureManager = new Class({
|
|||
*
|
||||
* See the methods available on the `DynamicTexture` class for more details.
|
||||
*
|
||||
* Optionally, you can also pass a Dynamic Texture instance to this method to have
|
||||
* it added to the Texture Manager.
|
||||
*
|
||||
* @method Phaser.Textures.TextureManager#addDynamicTexture
|
||||
* @fires Phaser.Textures.Events#ADD
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {string} key - The string-based key of this Texture. Must be unique within the Texture Manager.
|
||||
* @param {number} [width=256] - The width of this Dymamic Texture in pixels. Defaults to 256 x 256.
|
||||
* @param {number} [height=256] - The height of this Dymamic Texture in pixels. Defaults to 256 x 256.
|
||||
* @param {(string|Phaser.Textures.DynamicTexture)} key - The string-based key of this Texture. Must be unique within the Texture Manager. Or, a DynamicTexture instance.
|
||||
* @param {number} [width=256] - The width of this Dynamic Texture in pixels. Defaults to 256 x 256. Ignored if an instance is passed as the key.
|
||||
* @param {number} [height=256] - The height of this Dynamic Texture in pixels. Defaults to 256 x 256. Ignored if an instance is passed as the key.
|
||||
*
|
||||
* @return {?Phaser.Textures.DynamicTexture} The Dynamic Texture that was created, or `null` if the key is already in use.
|
||||
*/
|
||||
|
@ -736,15 +739,27 @@ var TextureManager = new Class({
|
|||
{
|
||||
var texture = null;
|
||||
|
||||
if (this.checkKey(key))
|
||||
if (typeof(key) === 'string' && !this.exists(key))
|
||||
{
|
||||
texture = new DynamicTexture(this, key, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
texture = key;
|
||||
key = texture.key;
|
||||
}
|
||||
|
||||
if (this.checkKey(key))
|
||||
{
|
||||
this.list[key] = texture;
|
||||
|
||||
this.emit(Events.ADD, key, texture);
|
||||
this.emit(Events.ADD_KEY + key, texture);
|
||||
}
|
||||
else
|
||||
{
|
||||
texture = null;
|
||||
}
|
||||
|
||||
return texture;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue