draw_sprite_stretched

This function simply takes a sprite resource and stretches it over the given width and height so that it occupies that area. As with draw_sprite() you can specify a sprite and a sub-image for drawing, then the x / y position in the room for the sprite to be drawn at and finally a width and a height (which must be pixel values). The image below shows the result of this function with different sets of arguments:

draw_sprite_stretched example

NOTE When drawing with this function, the sprite x offset and y offset (or origins) are ignored and the sprite is drawn with the top-left corner at the specified x/y position in the room.

If used with a Nine Slice enabled sprite, it will retain any detail after scaling depending on your Nine Slice settings in the Sprite Editor. See the page on Nine Slice for more information.

 

Syntax:

draw_sprite_stretched(sprite, subimg, x, y, w, h);

ArgumentTypeDescription
spriteSprite AssetThe index of the sprite to draw.
subimgRealThe subimg (frame) of the sprite to draw (image_index or -1 correlate to the current frame of animation in the object).
xRealThe x coordinate of where to draw the sprite.
yRealThe y coordinate of where to draw the sprite.
wRealThe width of the area the stretched sprite will occupy.
hRealThe height of the area the stretched sprite will occupy.

 

Returns:

N/A

 

Example:

draw_sprite_stretched(sprite_index, image_index, x, y, sprite_width, sprite_height / 2);

This will draw the instance's assigned sprite and its sub-image with the left corner at the instance x/y position. Its width is set to the same as the sprite, and the height is the sprite height divided by two.