sprite_get_uvs

This function returns an array with the UV coordinates and other data for the texture of the sprite sub-image on the texture page. The function returns an array with the following 8 elements:

This array can then be used in other draw functions, particularly when working in 3D or using the Primitive functions, as well as when working with the Shader functions.

NOTE This function will not work with vector sprites or skeleton animation sprites.

 

Syntax:

sprite_get_uvs(sprite, subimage);

Argument Type Description
sprite Sprite Asset The index of the sprite to use.
subimage Real The sub-image of the sprite to use.

 

Returns

Array (1D, 8 elements)

 

Example:

var _tex = sprite_get_uvs(sprite, 0);
tex_left = _tex[0];
tex_top = _tex[1];
tex_right = _tex[2];
tex_bottom = _tex[3];

The above code will store the UV coordinates for the given sprite in a local array and then assign the values to instance variables.