BatchHandlerTileSprite
A RenderNode that handles batch rendering of TileSprite and Tile game objects in WebGL. It extends BatchHandlerQuad by passing per-vertex frame data (the texture coordinate origin and dimensions of the source frame) to the shader, enabling the shader to correctly clamp or wrap texture coordinates within the bounds of the frame. This is essential for tiled sprites, where a texture is repeated or scrolled across a surface and must not bleed into neighbouring frames on a texture atlas.
Two additional render options are supported: clampFrame, which prevents texture coordinates from sampling outside the frame region, and wrapFrame, which tiles the frame region. These options are managed dynamically so that shader variants are compiled and swapped only when the options change.
Constructor
new BatchHandlerTileSprite(manager, [config])
Parameters
| name | type | optional | description |
|---|---|---|---|
| manager | Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager | No | The manager that owns this RenderNode. |
| config | Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfig | Yes | The configuration object for this handler. |
Scope: static
Extends
Source: src/renderer/webgl/renderNodes/BatchHandlerTileSprite.js#L26
Since: 4.0.0
Inherited Methods
From Phaser.Renderer.WebGL.RenderNodes.BatchHandler:
From Phaser.Renderer.WebGL.RenderNodes.BatchHandlerQuad:
- batchTextures
- finalizeTextureCount
- pushCurrentBatchEntry
- run
- setupTextureUniforms
- setupUniforms
- updateTextureCount
From Phaser.Renderer.WebGL.RenderNodes.RenderNode:
Public Methods
batch
<instance> batch(drawingContext, glTexture, x0, y0, x1, y1, x2, y2, x3, y3, texX, texY, texWidth, texHeight, tintMode, tintTL, tintBL, tintTR, tintBR, renderOptions, u0, v0, u1, v1, u2, v2, u3, v3)
Description:
Adds a textured quad to the batch for rendering as a TileSprite or Tile. Each vertex receives the full frame region (texX, texY, texWidth, texHeight) so that the shader can clamp or wrap UV coordinates within the frame bounds. If the batch is full after this call, it is flushed immediately. If the render options differ from those used by the current batch, the batch is also flushed and the shader configuration is updated before the new quad is written.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| drawingContext | Phaser.Renderer.WebGL.DrawingContext | No | The current drawing context. |
| glTexture | Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | No | The texture to render. |
| x0 | number | No | The x-coordinate of the top-left corner. |
| y0 | number | No | The y-coordinate of the top-left corner. |
| x1 | number | No | The x-coordinate of the bottom-left corner. |
| y1 | number | No | The y-coordinate of the bottom-left corner. |
| x2 | number | No | The x-coordinate of the top-right corner. |
| y2 | number | No | The y-coordinate of the top-right corner. |
| x3 | number | No | The x-coordinate of the bottom-right corner. |
| y3 | number | No | The y-coordinate of the bottom-right corner. |
| texX | number | No | The left u coordinate (0-1). |
| texY | number | No | The top v coordinate (0-1). |
| texWidth | number | No | The width of the texture (0-1). |
| texHeight | number | No | The height of the texture (0-1). |
| tintMode | Phaser.TintModes | No | The tint mode to use. |
| tintTL | number | No | The tint color for the top-left corner. |
| tintBL | number | No | The tint color for the bottom-left corner. |
| tintTR | number | No | The tint color for the top-right corner. |
| tintBR | number | No | The tint color for the bottom-right corner. |
| renderOptions | Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerQuadRenderOptions | No | Optional render features. |
| u0 | number | No | The u coordinate of the distorted top-left corner. |
| v0 | number | No | The v coordinate of the distorted top-left corner. |
| u1 | number | No | The u coordinate of the distorted bottom-left corner. |
| v1 | number | No | The v coordinate of the distorted bottom-left corner. |
| u2 | number | No | The u coordinate of the distorted top-right corner. |
| v2 | number | No | The v coordinate of the distorted top-right corner. |
| u3 | number | No | The u coordinate of the distorted bottom-right corner. |
| v3 | number | No | The v coordinate of the distorted bottom-right corner. |
Overrides: Phaser.Renderer.WebGL.RenderNodes.BatchHandlerQuad#batch
Source: src/renderer/webgl/renderNodes/BatchHandlerTileSprite.js#L194
Since: 4.0.0
updateRenderOptions
<instance> updateRenderOptions(renderOptions)
Description:
Reads the incoming render options and compares them against the currently active options. If any TileSprite-specific option has changed (clampFrame, wrapFrame, or the derived texRes flag), the internal change flag is set so that updateShaderConfig will update the active shader additions before the next draw call. Also calls the parent BatchHandlerQuad implementation to handle shared render options.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| renderOptions | Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerQuadRenderOptions | No | The render options to apply. |
Overrides: Phaser.Renderer.WebGL.RenderNodes.BatchHandlerQuad#updateRenderOptions
Source: src/renderer/webgl/renderNodes/BatchHandlerTileSprite.js#L111
Since: 4.0.0
updateShaderConfig
<instance> updateShaderConfig()
Description:
Applies any pending render option changes to the active shader program by enabling or disabling the TexCoordFrameClamp and TexCoordFrameWrap shader additions as required. This is called after the current batch has been flushed whenever updateRenderOptions detects a change. Also calls the parent BatchHandlerQuad implementation to handle shared shader configuration.
Overrides: Phaser.Renderer.WebGL.RenderNodes.BatchHandlerQuad#updateShaderConfig
Source: src/renderer/webgl/renderNodes/BatchHandlerTileSprite.js#L156
Since: 4.0.0
Inherited Members
From Phaser.Renderer.WebGL.RenderNodes.BatchHandler:
- batchEntries
- bytesPerIndexPerInstance
- bytesPerInstance
- currentBatchEntry
- floatsPerInstance
- indexBuffer
- indicesPerInstance
- instanceCount
- instancesPerBatch
- maxTexturesPerBatch
- programManager
- vertexBufferLayout
- verticesPerInstance
From Phaser.Renderer.WebGL.RenderNodes.BatchHandlerQuad:
From Phaser.Renderer.WebGL.RenderNodes.RenderNode: