Skip to content

Commit 261cb79

Browse files
committed
Added addRenderTexture method.
1 parent 3efc800 commit 261cb79

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

src/textures/TextureManager.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,34 @@ var TextureManager = new Class({
341341
return texture;
342342
},
343343

344+
/**
345+
* Adds a Render Texture to the Texture Manager using the given key.
346+
* This allows you to then use the Render Texture as a normal texture for texture based Game Objects like Sprites.
347+
*
348+
* @method Phaser.Textures.TextureManager#addRenderTexture
349+
* @since 3.12.0
350+
*
351+
* @param {string} key - The unique string-based key of the Texture.
352+
* @param {Phaser.GameObjects.RenderTexture} renderTexture - The source Render Texture.
353+
*
354+
* @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use.
355+
*/
356+
addRenderTexture: function (key, renderTexture)
357+
{
358+
var texture = null;
359+
360+
if (this.checkKey(key))
361+
{
362+
texture = this.create(key, renderTexture);
363+
364+
texture.add('__BASE', 0, 0, 0, renderTexture.width, renderTexture.height);
365+
366+
this.emit('addtexture', key, texture);
367+
}
368+
369+
return texture;
370+
},
371+
344372
/**
345373
* Creates a new Texture using the given config values.
346374
* Generated textures consist of a Canvas element to which the texture data is drawn.

0 commit comments

Comments
 (0)