Skip to main content
Version: Phaser v4.0.0

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

nametypeoptionaldescription
managerPhaser.Renderer.WebGL.RenderNodes.RenderNodeManagerNoThe manager that owns this RenderNode.
configPhaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfigYesThe configuration object for this handler.

Scope: static

Extends

Phaser.Renderer.WebGL.RenderNodes.BatchHandlerQuad

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:

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:

nametypeoptionaldescription
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.
glTexturePhaser.Renderer.WebGL.Wrappers.WebGLTextureWrapperNoThe texture to render.
x0numberNoThe x-coordinate of the top-left corner.
y0numberNoThe y-coordinate of the top-left corner.
x1numberNoThe x-coordinate of the bottom-left corner.
y1numberNoThe y-coordinate of the bottom-left corner.
x2numberNoThe x-coordinate of the top-right corner.
y2numberNoThe y-coordinate of the top-right corner.
x3numberNoThe x-coordinate of the bottom-right corner.
y3numberNoThe y-coordinate of the bottom-right corner.
texXnumberNoThe left u coordinate (0-1).
texYnumberNoThe top v coordinate (0-1).
texWidthnumberNoThe width of the texture (0-1).
texHeightnumberNoThe height of the texture (0-1).
tintModePhaser.TintModesNoThe tint mode to use.
tintTLnumberNoThe tint color for the top-left corner.
tintBLnumberNoThe tint color for the bottom-left corner.
tintTRnumberNoThe tint color for the top-right corner.
tintBRnumberNoThe tint color for the bottom-right corner.
renderOptionsPhaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerQuadRenderOptionsNoOptional render features.
u0numberNoThe u coordinate of the distorted top-left corner.
v0numberNoThe v coordinate of the distorted top-left corner.
u1numberNoThe u coordinate of the distorted bottom-left corner.
v1numberNoThe v coordinate of the distorted bottom-left corner.
u2numberNoThe u coordinate of the distorted top-right corner.
v2numberNoThe v coordinate of the distorted top-right corner.
u3numberNoThe u coordinate of the distorted bottom-right corner.
v3numberNoThe 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:

nametypeoptionaldescription
renderOptionsPhaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerQuadRenderOptionsNoThe 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:

From Phaser.Renderer.WebGL.RenderNodes.BatchHandlerQuad:

From Phaser.Renderer.WebGL.RenderNodes.RenderNode: