Stores a copy of this Render Texture in the Texture Manager using the given key.
After doing this, any texture based Game Object, such as a Sprite, can use the contents of this Render Texture by using the texture key:
var rt = this.add.renderTexture(0, 0, 128, 128);
// Draw something to the Render Texture
rt.saveTexture('doodle');
this.add.image(400, 300, 'doodle');
Updating the contents of this Render Texture will automatically update any Game Object
that is using it as a texture. Calling saveTexture
again will not save another copy
of the same texture, it will just rename the key of the existing copy.
By default it will create a single base texture. You can add frames to the texture
by using the Texture.add
method. After doing this, you can then allow Game Objects
to use a specific frame from a Render Texture.
If you destroy this Render Texture, any Game Object using it via the Texture Manager will stop rendering. Ensure you remove the texture from the Texture Manager and any Game Objects using it first, before destroying this Render Texture.
name | type | description |
---|---|---|
key | string |
The unique key to store the texture as within the global Texture Manager. |
The Texture that was saved.