Phaser API Documentation

  Version: 
copySprite(source, target, [clear], [clearAlpha], [eraseMode], [colorMatrix], [shader])

Description:

Copy the source Render Target to the target Render Target.

No target resizing takes place. If the source Render Target is larger than the target, then only a portion the same size as the target dimensions is copied across.

Calling this method will invoke the onCopySprite handler and will also call the onFXCopy callback on the Sprite. Both of these happen prior to the copy, allowing you to use them to set shader uniforms and other values.

You can optionally pass in a ColorMatrix. If so, it will use the ColorMatrix shader during the copy, allowing you to manipulate the colors to a fine degree. See the ColorMatrix class for more details.

Parameters:

name type arguments Default description
source Phaser.Renderer.WebGL.RenderTarget

The source Render Target being copied from.

target Phaser.Renderer.WebGL.RenderTarget

The target Render Target that will be copied to.

clear boolean <optional> true

Clear the target before copying?

clearAlpha boolean <optional> true

Clear the alpha channel when running gl.clear on the target?

eraseMode boolean <optional> false

Erase source from target using ERASE Blend Mode?

colorMatrix Phaser.Display.ColorMatrix <optional>

Optional ColorMatrix to use when copying the Sprite.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to use to copy the target. Defaults to the copyShader.

Since: 3.60.0