Function setSprite2DUvOffset
-
setSprite2DUvOffset(
layer: Sprite2DLayer,
index: number,
uvOffset: readonly [number, number],
): voidParameters
- layer: Sprite2DLayer
The sprite layer to scroll.
- index: number
Index of the sprite within the layer.
- uvOffset: readonly [number, number]
The UV offset
[u, v]added to the sprite's sampled UV.
Returns void
- layer: Sprite2DLayer
Set (and enable) the per-sprite UV scroll offset for one sprite of
layer. The two floats are added to the sprite's sampled UV in the vertex stage — driving parallax / infinite-scroll backgrounds without re-uploading texture coordinates.Opt-in & tree-shakable: importing this function is what pulls the uvScroll widening into the bundle. The first call on a layer enables scroll: it widens the layer's instance layout by two floats per sprite (re-striding existing sprites once) and flips it to the wide layout; subsequent calls just write the offset. There is no create-time option — a layer is always created narrow and opts into scroll the first time this setter is used.