SetSpriteUVOffset

Description

Offsets the sprites UV coordinates by the given amount. For example, offsetting by 0.5 in the U direction will make the sprite begin sampling the texture halfway across the top of the texture instead of the top left corner as normal. UV values outside the range of 0,0 (top left) and 1,1 (bottom right) can either wrap around or clamp the texture, which is decided by the image assigned to the sprite using SetImageWrapU and SetImageWrapV. Clamping or wrapping cannot be set on a per-sprite basis.

By default a sprite is set to use the UV coordinates 0,0 to 1,1 using the full image available to it. However there are several cases where this is changed by the AGK to hide certain limitations. If the texture assigned to the sprite is not a power of 2 width or height the image is increased in size until it is a power of 2 size and the UV coordinates for the sprite reduced so that the sprite only uses the portion of the texture containing the original image. This is because most mobile platforms do not support textures that are not a power of 2 width or height. Therefore offsetting the sprite's UV coordinates in this case will shift the sprite's usage of the texture into the undefined portion which is being used as padding.

Additionally if the sprite is using an image that belongs to an atlas texture the sprite's UV coordinates will be set so that it only uses the portion of the texture containing its assigned image. Offsetting the UV coordinates in this case will shift the sprite's usage of the texture into other images that are part of the atlas texture. The same can be said of sprites using an animation contained within a single texture using SetSpriteAnimation.

Due to these possibilities it is recommended that UV coordinates only be modified on sprites that are using whole images (not atlas textures) and which are a power of 2 size in both width and height. With these constraints it is possible to use UV values outside 0-1 to clamp or repeat the texture successfully.

Definition

SetSpriteUVOffset( iSpriteIndex, u, v )

Parameters