sprite_add_from_surface

Adds an area of a surface as a next subimage to a sprite.

Syntax:

sprite_add_from_surface(index, surface, x, y, w, h, removeback, smooth);


Argument Description
index The index of the sprite to add the new image to.
surface The index of the surface from which the get the image.
x The x position to copy from.
y The y position to copy from.
w The width of the area to be copied (from the x position).
h The height of the area to be copied (from the y position).
removeback Indicates whether to make all pixels with the background colour (left-bottom pixel) transparent.
smooth Indicates whether to smooth the edges.


Returns: N/A


Description

This function works in exactly the same way as sprite_create_from_surface only instead of creating a new sprite from the area of the indexed surface that you select, it adds the defined area of the surface as a new sub-image to a previously created sprite.


Example:

spr_custom = sprite_create_from_surface(surf, 0, 0, 32, 32, true, true, 16, 16);
var i;
for (i = 1; i < 8; i +=1)
   {
   sprite_add_from_surface(spr_Custom, surf, i, 0, 32, 32, true, true, 16, 16);
   }

The above code creates a sprite from the surface indexed in the variable "surf", assigning its index to the variable "spr_Custom", and then uses a for loop to move across the surface and capture various sections which are added into the sprite as sub-images.


Back: Sprites
Next: sprite_collision_mask
© Copyright YoYo Games Ltd. 2018 All Rights Reserved