This function returns a special pointer for the sprite on its texture page. This value can then be used in other draw functions, particularly in the 2D primitive functions, as well as the Shader functions. You can get more information about the returned texture page using the different texture_ functions found on the Textures page.
NOTE On HTML5, this returns a struct instead of a texture pointer, as a pointer cannot be used on that platform. However this does not change the use of the returned value, as its usage in texture functions still remains the same.
sprite_get_texture(spr, subimg);
Argument | Type | Description |
---|---|---|
spr | Sprite Asset | The index of the sprite to use. |
subimg | Real | The sub-image of the sprite to use. |
var _tex;
_tex = sprite_get_texture(spr_Wall, 0);
draw_primitive_begin_texture(pr_trianglestrip, _tex);
draw_vertex_texture(0, 0, 0, 0);
draw_vertex_texture(480, 0, 1, 0);
draw_vertex_texture(480, 640, 1, 1);
draw_vertex_texture(0, 640, 0, 1);
draw_primitive_end();
The above code will draw a 4 vertex triangle strip textured with the texture held in the tex variable.