Use this method if you have already called beginDraw
and need to batch
draw a large number of texture frames to this Dynamic Texture.
This method batches the drawing of the given frames to this Dynamic Texture, without causing a WebGL bind or batch flush for each one.
It is faster than calling drawFrame
, but you must be 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:
DynamicTexture.beginDraw();
// repeat n times:
DynamicTexture.batchDraw();
// or
DynamicTexture.batchDrawFrame();
// Call once:
DynamicTexture.endDraw();
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 Dynamic Texture while the
batch is still open. Doing so will cause a run-time error in the WebGL Renderer.
You can use the DynamicTexture.isDrawing
boolean property to tell if a batch is
currently open, or not.
Textures are referenced by their string-based keys, as stored in the Texture Manager.
You can optionally provide a position, alpha and tint value to apply to the frame before it is drawn.
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. |
|
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. Game Objects use their own alpha. |
tint | number | <optional> | 0xffffff |
The tint color value. Only used when drawing Texture Frames to this texture. Game Objects use their own tint. WebGL only. |
This Dynamic Texture instance.