Returns the texture coordinates of the sprite within the texture page as an array.


GML Code Example

sprite_get_uvs(sprite, subimage);

Argument Description
sprite The index of the sprite to use.
subimage The sub-image of the sprite to use.

Returns: Array


This function returns an array with the UV coordinates for the texture of the sprite sub-image on the texture page, filling in the array with the following values: [0] = left, [1] = top, [2] = right and [3] = bottom. This value can then be used in other draw functions, particularly in general 3D and some of the 2D primitive functions, as well as the Shader functions.

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


GML Code 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.

Back: Sprites

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here