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.
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 (this means that you cannot add it directly to a sprite from the resource tree, but rather only to one previously created from a surface, or one that has been duplicated from a resource sprite using sprite_duplicate).IMPORTANT! This function is not available with the Trial Licence of the product.
spr_custom = sprite_create_from_surface(surf, 0, 0,
32, 32, true, true, 16, 16);
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.