@@ -259,6 +259,41 @@ var RenderTexture = new Class({
259259 return this ;
260260 } ,
261261
262+ /**
263+ * Stores a copy of this Render Texture in the Texture Manager using the given key.
264+ *
265+ * After doing this, any texture based Game Object, such as a Sprite, can use the contents of this
266+ * Render Texture for its texture by using the texture key:
267+ *
268+ * ```javascript
269+ * var rt = this.add.renderTexture(0, 0, 128, 128);
270+ *
271+ * // Draw something to the Render Texture
272+ *
273+ * rt.saveTexture('doodle');
274+ *
275+ * this.add.image(400, 300, 'doodle');
276+ * ```
277+ *
278+ * Updating the contents of this Render Texture will automatically update _any_ Game Object
279+ * that is using it as a texture.
280+ *
281+ * By default it will create a single base texture. You can add frames to the texture
282+ * by using the `Texture.add` method. After doing this, you can then allow Game Objects
283+ * to use a specific frame from a Render Texture.
284+ *
285+ * @method Phaser.GameObjects.RenderTexture#saveTexture
286+ * @since 3.12.0
287+ *
288+ * @param {string } key - The unique key to store the texture as within the global Texture Manager.
289+ *
290+ * @return {?Phaser.Textures.Texture } The Texture that was created, or `null` if it could not be saved.
291+ */
292+ saveTexture : function ( key )
293+ {
294+ return this . textureManager . addRenderTexture ( key , this ) ;
295+ } ,
296+
262297 /**
263298 * Internal destroy handler, called as part of the destroy process.
264299 *
@@ -280,40 +315,6 @@ var RenderTexture = new Class({
280315 }
281316 }
282317
283- /**
284- * Fills the Render Texture with the given color.
285- *
286- * @method Phaser.GameObjects.RenderTexture#fill
287- * @since 3.2.0
288- *
289- * @param {number } rgb - The color to fill the Render Texture with.
290- *
291- * @return {Phaser.GameObjects.RenderTexture } This Game Object.
292- */
293-
294- /**
295- * Clears the Render Texture.
296- *
297- * @method Phaser.GameObjects.RenderTexture#clear
298- * @since 3.2.0
299- *
300- * @return {Phaser.GameObjects.RenderTexture } This Game Object.
301- */
302-
303- /**
304- * Draws a texture frame to the Render Texture at the given position.
305- *
306- * @method Phaser.GameObjects.RenderTexture#draw
307- * @since 3.2.0
308- *
309- * @param {string } texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
310- * @param {(string|integer) } [frame] - An optional frame from the Texture this Game Object is rendering with.
311- * @param {number } x - The x position to draw the frame at.
312- * @param {number } y - The y position to draw the frame at.
313- *
314- * @return {Phaser.GameObjects.RenderTexture } This Game Object.
315- */
316-
317318} ) ;
318319
319320module . exports = RenderTexture ;
0 commit comments