Phaser API Documentation

  Version: 
saveTexture(key, [flipY])

Description:

Stores this Video in the Texture Manager using the given key as a dynamic texture, which any texture-based Game Object, such as a Sprite, can use as its texture:

var vid = this.add.video(0, 0, 'intro');

vid.play();

vid.saveTexture('doodle');

this.add.image(400, 300, 'doodle');

The saved texture is automatically updated as the video plays. If you pause this video, or change its source, then the saved texture updates instantly.

Calling saveTexture again will not save another copy of the same texture, it will just rename the existing one.

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.

If you intend to save the texture so you can use it as the input for a Shader, you may need to set the flipY parameter to true if you find the video renders upside down in your shader.

Parameters:

name type arguments Default description
key string

The unique key to store the texture as within the global Texture Manager.

flipY boolean <optional> false

Should the WebGL Texture set UNPACK_MULTIPLY_FLIP_Y during upload?

Returns:
Description:

The Texture that was saved.

Since: 3.20.0