Phaser API Documentation

  Version: 
drawFrame(key, [frame], [x], [y], [alpha], [tint])

Description:

Draws the Texture Frame to the Render Texture at the given position.

Textures are referenced by their string-based keys, as stored in the Texture Manager.

var rt = this.add.renderTexture(0, 0, 800, 600);
rt.drawFrame(key, frame);

You can optionally provide a position, alpha and tint value to apply to the frame before it is drawn.

Calling this method will cause a batch flush, so if you've got a stack of things to draw in a tight loop, try using the draw method instead.

If you need to draw a Sprite to this Render Texture, use the draw method instead.

If you are not planning on using this Dynamic Texture as a base texture for Sprite Game Objects, then you should set DynamicTexture.isSpriteTexture = false before calling this method, otherwise you will get vertically inverted frames in WebGL.

Parameters:

name type arguments Default description
key string

The key of the texture to be used, as stored in the Texture Manager.

frame string | number <optional>

The name or index of the frame within the Texture. Set to null to skip this argument if not required.

x number <optional> 0

The x position to draw the frame at.

y number <optional> 0

The y position to draw the frame at.

alpha number <optional> 1

The alpha value. Only used when drawing Texture Frames to this texture.

tint number <optional> 0xffffff

The tint color value. Only used when drawing Texture Frames to this texture. WebGL only.

Returns:
Description:

This Dynamic Texture instance.

Since: 3.12.0