sprite_get_texture

Returns the texture id for the given sprite and sub-image.

Syntax:

GML Code Example

sprite_get_texture(spr, subimg);


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


Returns: pointer


Description

This function returns a special pointer for the sprite texture. 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.


Example:

GML Code Example

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.


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