Phaser API Documentation

batchDrawFrame(key, [frame], [x], [y], [alpha], [tint])


Use this method if you have already called beginDraw and need to batch draw a large number of texture frames to this Render Texture.

This method batches the drawing of the given frames to this Render Texture, without causing a bind or batch flush.

It is faster than calling drawFrame, but you must be very careful to manage the flow of code and remember to call endDraw(). If you don't need to draw large numbers of frames it's much safer and easier to use the drawFrame method instead.

The flow should be:

// Call once:

// repeat n times:
// or

// Call once:

Do not call any methods other than batchDraw, batchDrawFrame, or endDraw once you have started a batch. Also, be very careful not to destroy this Render Texture while the batch is still open, or call beginDraw again.

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.


name type arguments 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.

x number <optional>

The x position to draw the frame at.

y number <optional>

The y position to draw the frame at.

alpha number <optional>

The alpha to use. If not specified it uses the globalAlpha property.

tint number <optional>

WebGL only. The tint color to use. If not specified it uses the globalTint property.


This Render Texture instance.