SetSpriteUVScale

Description

Scales the sprites UV coordinates by the given amount. A sprite with UV scaled by 2 will make its texture look twice as big as normal. The UV scale does not affect the UV offset chosen using SetSpriteUVOffset, so that an offset of 0.5 in the U direction will always begin sampling halfway across the texture, the scale defines how far the sprite continues sampling. So with an offset of 0.5, a scale of 2 will make the sprite sample from 0.5 to 1 instead of 0.5 to 1.5.

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

SetSpriteUVScale( iSpriteIndex, scaleU, scaleV )

Parameters